22035ERRORTier 2 — Caution✅ HIGH confidenceno SQL/JSON item
Category: Data ExceptionVersions: Postgres 14+
What this means
SQLSTATE 22035 is raised when a SQL/JSON path expression in a strict mode context matches no items and an error should be raised rather than returning an empty result.
Why it happens
- 1A SQL/JSON path query in strict mode finds no matching elements in the JSON value
How to reproduce
SQL/JSON strict mode path with no match.
trigger — this will ERROR
SELECT jsonb_path_query('{"a":1}'::jsonb, 'strict $.b');ERROR: jsonpath member accessor can only be applied to an object
Fix 1: Use lax mode (default) to return empty set instead of error
When the path may not match and an empty result is acceptable.
fix
SELECT jsonb_path_query('{"a":1}'::jsonb, 'lax $.b');Why this works
Lax mode suppresses errors for missing keys and returns an empty sequence, which is usually more practical.
Fix 2: Check for key existence before accessing
When the key may be optional.
fix
SELECT jsonb_path_query('{"a":1}'::jsonb, '$.b') WHERE '{"a":1}'::jsonb ? 'b';Why this works
The ? operator checks for key existence before the path query.
Version notes
Postgres 14+Strict/lax mode distinction refined in Postgres 14.Sources
📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html
🔧 Source ref: Class 22 — Data Exception
Confidence assessment
✅ HIGH confidence
Standard SQLSTATE for SQL/JSON strict mode no-match. Stable since Postgres 14.
See also
📄 Reference pages
SQL/JSON Path Languagejsonb_path_query
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →