A PostgREST-shaped error: HTTP status plus the code, message, details and
hint body fields. headers are response headers the error carries: PgRest.Responder
sends them without adding an authentication challenge. A headerless PgRest 401
defaults to www-authenticate: Bearer; custom_headers?: true preserves an empty
custom RAISE header map without that default.
Differences from PostgREST
Changeset validation errors return 400/23514 with string details; PostgREST has no application changesets.
Summary
Functions
PGRST123: an aggregate in select= while aggregates are disabled.
PGRST203: several functions match equally well (300). candidates are the schema.name(arg => type, ...) texts.
A body larger than max_body_bytes (413, Postgres 54000).
The write check failed: a written row is outside the resource's scope.
PGRST204: a payload or columns= name is not a column of the table.
PGRST000: PostgREST's 503 for a failed database connection; the driver's text is not sent.
PGRST202: no function matches the request (404). keys are the argument names the request
carries; post? adds the single-unnamed-parameter alternative to the details.
PGRST202 for a POST whose body is not JSON: only a function with one unnamed parameter of
type (text, xml or bytea) can take it, so no argument names are reported.
A generic 500 for a configuration problem; the cause is logged, never sent.
22P02 for a filter value the column's type rejects, raised before the query reaches
Postgres (PgRest.Ecto.Filter casts values with the Ecto field type).
PGRST102: a request body that is not JSON.
PGRST125: the path is not /<table>.
A 400 23514 for a payload the resource's changeset/3 (or the column types) rejects, as
a Postgres check violation would be. details is a string (field: message; ...), the
type PostgrestError.details has. PgRest only: PostgREST has no changesets.
PGRST122: handling=strict and tokens are not valid preferences.
PGRST103: an unsatisfiable Range header or a negative limit.
PGRST106: an Accept-Profile/Content-Profile naming a schema that is not exposed (406).
A 401 for a token that cannot be used: PGRST301 (:decode, the token is malformed or its
signature is wrong) or PGRST303 (:claims, a claim is invalid), with PostgREST's
www-authenticate: Bearer error="invalid_token", error_description="<message>".
PGRST102: the rows of a bulk payload do not all have the same keys.
PGRST124: handling=strict and the statement affected more than max-affected rows.
PGRST128: handling=strict with max-affected on a function that does not return a set.
PGRST200: no relationship from parent to the embed name in schema. using is the
request's embed hint, hint the suggestion (both may be nil).
PGRST108: an embedded parameter names an embed that is not in the select.
22023: Postgres' own message when columns= lets a non-object element through.
PGRST103: the requested offset is past the known total.
Builds a 400 PGRST100 error, the code PostgREST uses for unparseable request text.
42501 for a table or a function the request may not use: permission denied for table <name> or permission denied for function <name>, 401 for :anon and 403 otherwise (the
responder adds www-authenticate: Bearer to a 401).
PGRST003: no pool connection within the queue timeout (504).
PGRST105: a PUT whose filters are not exactly an eq on every primary key column (405).
PGRST114: limit/offset on a PUT.
PGRST115: no payload row of a PUT has the URL's primary key values.
PGRST118: order=<relation>(<column>) on an embed that is not to-one.
Malformed response GUC (PGRST111 headers or PGRST112 status).
PGRST101: an RPC request with a method other than GET, HEAD or POST (405).
PGRST002: the schema cache (the registry snapshot) is not available yet (503).
PGRST116: a single object was requested and the result has count rows.
PGRST102: a PATCH payload that is an array of more than one object. A documented difference:
PostgREST applies one of the objects arbitrarily.
PGRST102: a PUT payload with several objects that match the URL's key. A documented difference: PostgREST fails with a 500 21000.
PGRST127: an aggregate inside a spread that cannot hoist it: a one-to-many or many-to-many
spread (as PostgREST), or a spread over a resource with after_load/2, whose columns are merged
after the query (PgRest only).
A table denial for a resource/config and request context or resolved role.
PGRST205: no such table in the schema cache.
Returns the JSON body map. All four keys are always present; nil encodes as
JSON null.
PostgREST's 401 PGRST302: a request without a token where anonymous access is off.
A bulk payload with more rows than max_bulk_rows (413, Postgres 54000).
Postgres' own 42703 for a bare column name (an on_conflict= target).
PostgREST's 42703 for a column the table does not have.
Postgres' 22023 for a role that does not exist, which PostgREST answers with a 401.
PGRST102: the request body could not be read.
PGRST107: none of the Accept media types is supported.
PGRST117: the HTTP method is not supported.
21000: a PATCH or DELETE without a filter while require_filters_for_mutations is on.
The status, code and message are those of Supabase's pg-safeupdate.
Types
Functions
@spec aggregates_not_allowed() :: t()
PGRST123: an aggregate in select= while aggregates are disabled.
PGRST203: several functions match equally well (300). candidates are the schema.name(arg => type, ...) texts.
@spec body_too_large() :: t()
A body larger than max_body_bytes (413, Postgres 54000).
The write check failed: a written row is outside the resource's scope.
PGRST204: a payload or columns= name is not a column of the table.
@spec connection_error() :: t()
PGRST000: PostgREST's 503 for a failed database connection; the driver's text is not sent.
@spec function_not_found( String.t(), String.t(), [String.t()], boolean(), String.t() | nil ) :: t()
PGRST202: no function matches the request (404). keys are the argument names the request
carries; post? adds the single-unnamed-parameter alternative to the details.
PGRST202 for a POST whose body is not JSON: only a function with one unnamed parameter of
type (text, xml or bytea) can take it, so no argument names are reported.
@spec internal() :: t()
A generic 500 for a configuration problem; the cause is logged, never sent.
22P02 for a filter value the column's type rejects, raised before the query reaches
Postgres (PgRest.Ecto.Filter casts values with the Ecto field type).
@spec invalid_json() :: t()
PGRST102: a request body that is not JSON.
@spec invalid_path() :: t()
PGRST125: the path is not /<table>.
A 400 23514 for a payload the resource's changeset/3 (or the column types) rejects, as
a Postgres check violation would be. details is a string (field: message; ...), the
type PostgrestError.details has. PgRest only: PostgREST has no changesets.
PGRST122: handling=strict and tokens are not valid preferences.
PGRST103: an unsatisfiable Range header or a negative limit.
PGRST106: an Accept-Profile/Content-Profile naming a schema that is not exposed (406).
A 401 for a token that cannot be used: PGRST301 (:decode, the token is malformed or its
signature is wrong) or PGRST303 (:claims, a claim is invalid), with PostgREST's
www-authenticate: Bearer error="invalid_token", error_description="<message>".
@spec keys_must_match() :: t()
PGRST102: the rows of a bulk payload do not all have the same keys.
@spec max_affected_exceeded(non_neg_integer()) :: t()
PGRST124: handling=strict and the statement affected more than max-affected rows.
@spec max_affected_rpc() :: t()
PGRST128: handling=strict with max-affected on a function that does not return a set.
@spec no_relationship( String.t(), String.t(), String.t(), String.t() | nil, String.t() | nil ) :: t()
PGRST200: no relationship from parent to the embed name in schema. using is the
request's embed hint, hint the suggestion (both may be nil).
PGRST108: an embedded parameter names an embed that is not in the select.
@spec not_objects() :: t()
22023: Postgres' own message when columns= lets a non-object element through.
@spec offset_out_of_bounds(non_neg_integer(), non_neg_integer()) :: t()
PGRST103: the requested offset is past the known total.
Builds a 400 PGRST100 error, the code PostgREST uses for unparseable request text.
42501 for a table or a function the request may not use: permission denied for table <name> or permission denied for function <name>, 401 for :anon and 403 otherwise (the
responder adds www-authenticate: Bearer to a 401).
@spec pool_timeout() :: t()
PGRST003: no pool connection within the queue timeout (504).
@spec put_filters_not_key() :: t()
PGRST105: a PUT whose filters are not exactly an eq on every primary key column (405).
@spec put_limit_not_allowed() :: t()
PGRST114: limit/offset on a PUT.
@spec put_payload_mismatch() :: t()
PGRST115: no payload row of a PUT has the URL's primary key values.
@spec response_guc(:headers | :status) :: t()
Malformed response GUC (PGRST111 headers or PGRST112 status).
PGRST101: an RPC request with a method other than GET, HEAD or POST (405).
@spec schema_cache_not_ready() :: t()
PGRST002: the schema cache (the registry snapshot) is not available yet (503).
@spec single_object(non_neg_integer()) :: t()
PGRST116: a single object was requested and the result has count rows.
@spec single_patch_object() :: t()
PGRST102: a PATCH payload that is an array of more than one object. A documented difference:
PostgREST applies one of the objects arbitrarily.
@spec single_put_object() :: t()
PGRST102: a PUT payload with several objects that match the URL's key. A documented difference: PostgREST fails with a 500 21000.
@spec spread_aggregate_not_implemented(:to_many | :after_load) :: t()
PGRST127: an aggregate inside a spread that cannot hoist it: a one-to-many or many-to-many
spread (as PostgREST), or a spread over a resource with after_load/2, whose columns are merged
after the query (PgRest only).
A table denial for a resource/config and request context or resolved role.
PGRST205: no such table in the schema cache.
Returns the JSON body map. All four keys are always present; nil encodes as
JSON null.
@spec token_required() :: t()
PostgREST's 401 PGRST302: a request without a token where anonymous access is off.
@spec too_many_rows() :: t()
A bulk payload with more rows than max_bulk_rows (413, Postgres 54000).
Postgres' own 42703 for a bare column name (an on_conflict= target).
PostgREST's 42703 for a column the table does not have.
Postgres' 22023 for a role that does not exist, which PostgREST answers with a 401.
@spec unreadable_body() :: t()
PGRST102: the request body could not be read.
PGRST107: none of the Accept media types is supported.
PGRST117: the HTTP method is not supported.
@spec where_required(:update | :delete) :: t()
21000: a PATCH or DELETE without a filter while require_filters_for_mutations is on.
The status, code and message are those of Supabase's pg-safeupdate.