SQLSTATE 22035Severity lowLab verified

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.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
No SQL/JSON item for path (ON EMPTY)
What triggers it
Call JSON_VALUE(doc, path) where the path selects no item and the ON EMPTY clause is (or defaults to) ERROR.
The 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.

The fix

What to do right now

The immediate, application-level response to 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.
Fix — SQL
-- Provide a fallback with DEFAULT ... ON EMPTY.
SELECT JSON_VALUE('{"a":1}'::jsonb, '$.missing' DEFAULT 'n/a' ON EMPTY);

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed