Incident brief
No SQL/JSON item for path (ON EMPTY)
JSON_VALUE raises this when the path matches nothing and the ON EMPTY behavior is ERROR; a DEFAULT ... ON EMPTY clause avoids it.
What lands in your log
ERROR: no SQL/JSON item found for specified path
In 10 seconds
- What triggers it
- Call JSON_VALUE(doc, path) where the path selects no item and the ON EMPTY clause is (or defaults to) ERROR.
- Fix
- Add a DEFAULT <value> ON EMPTY clause so a missing path yields a fallback instead of an error.
- Proof
- Reproduced on PostgreSQL 18.4 → A single SELECT reproduces SQLSTATE 22035; a path that matches nothing errors under the default ON EMPTY = ERROR.
Fix
What to do right now
Application-level steps for this error.
- Add a DEFAULT <value> ON EMPTY clause so a missing path yields a fallback instead of an error.
- Or use NULL ON EMPTY when a missing path should simply be null.
-- PostgreSQL 17+: return NULL rather than raising on an empty path.
SELECT JSON_VALUE('{"a":1}'::jsonb, '$.missing' NULL ON EMPTY) AS missing_value;For this error
See this error live on the server
Run these against the affected instance to confirm the diagnosis before you act.
No SQL/JSON item for path (ON EMPTY) depends on SQL/JSON path cardinality. Check server version, then inspect the path with jsonb_path_query before choosing ON EMPTY/ON ERROR behavior.
SQL/JSON feature version
JSON_VALUE syntax is version-dependent; confirm the actual server before replaying documentation examples.
SELECT current_setting('server_version') AS server_version,
current_setting('server_version_num') AS server_version_num;Path result cardinality
Replace document/path with the failing values; this shows zero, one, or many items without forcing JSON_VALUE scalar semantics.
SELECT value
FROM jsonb_path_query(<json_document>::jsonb, <jsonpath_literal>) AS value;Why it happens
What PostgreSQL is telling you
The mechanism behind the error, grounded in the official manual, not paraphrased.
PostgreSQL 18 Documentation, Appendix A. PostgreSQL Error Codes (Table A.1, Class 22, Data Exception)
22035 → no_sql_json_itemRead the full section on postgresql.org →
Selecting a missing JSON path with ON EMPTY ERROR
The path matched no item and the default ON EMPTY behavior is ERROR, so PostgreSQL raises 'no SQL/JSON item found for specified path'.The session continues normally
The JSON_VALUE path lookup failed on its own, outside a transaction, so nothing carries over to session B's next statement.Reproduce & verify
A real, single-session PostgreSQL reproduction
A literal transcript of SQL run against a live PostgreSQL instance in an isolated lab. The commands below are exactly what was executed.
- 1Call JSON_VALUE(doc, path) where the path selects no item and the ON EMPTY clause is (or defaults to) ERROR.
- 2PostgreSQL evaluates the path, finds nothing, and applies the ON EMPTY = ERROR behavior.
- 3The statement aborts with SQLSTATE 22035 and 'no SQL/JSON item found for specified path'.
A query extracted an optional JSON field with JSON_VALUE and failed on documents where the field was absent.
-- The error is self-contained in one statement; no schema is required.
SELECT 'no schema needed' AS setup_note;SELECT JSON_VALUE('{"a":1}'::jsonb, '$.missing' ERROR ON EMPTY);SELECT 'ok' AS session_after_error;What PostgreSQL actually returned
setup_note
------------------
no schema needed
(1 row)ERROR: no SQL/JSON item found for specified path session_after_error
---------------------
ok
(1 row)The same extraction returns a fallback once ON EMPTY provides a default.
Without this
Before: a missing path errors
With this, tested
After: DEFAULT 'n/a' ON EMPTY returns the fallback
- A second operational test: exact SQL, raw output, measured result, and engineer notes
Card required. Cancel before day 7 and you are not charged.
Connected
Everything this error touches
Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.
Verification
- Last verified
- 2026-07-24 (isolated lab, PostgreSQL 18.4)
- Verification scope
- Verified against PostgreSQL 18.4 in an isolated lab environment
- Audit status
- reviewed
Went further?
Pro unlocks the second lab proof
Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.