2203A
PostgreSQLERRORNotableData ExceptionHIGH confidence

SQL/JSON member not found

What this means

SQLSTATE 2203A is raised when a SQL/JSON member accessor (dot operator) is applied to a JSON object and the specified key does not exist, in strict mode.

Why it happens
  1. 1SQL/JSON strict mode path expression accessing a key that does not exist in the JSON object
How to reproduce

Strict mode access to a non-existent JSON key.

trigger — this will error
trigger — this will error
SELECT jsonb_path_query('{"a":1}'::jsonb, 'strict $.b');

expected output

ERROR:  JSON object does not contain key "b"

Fix 1

Use lax mode to suppress the error for missing keys

WHEN When JSON keys may be optional.

Use lax mode to suppress the error for missing keys
SELECT jsonb_path_query('{"a":1}'::jsonb, 'lax $.b');

Why this works

Lax mode returns an empty sequence for missing keys instead of raising an error.

Fix 2

Check for key existence with the ? operator

WHEN When key presence needs to be explicitly tested.

Check for key existence with the ? operator
SELECT '{"a":1}'::jsonb ? 'b'; -- false

Why this works

The ? operator checks key existence without raising an error.

Version notes
Postgres 14+

SQL/JSON strict mode semantics refined in Postgres 14.

Sources
Official documentation ↗

Class 22 — Data Exception

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors