Skip to content

fix(postgrest): describe bodiless and non-JSON error responses with the status phrase, Proxy-Status code and decoded body - #2061

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2823-postgrest-useful-apierror-for-bodiless-and-non-json-errors
Nov 16, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2823-postgrest-useful-apierror-for-bodiless-and-non-json-errors

Conversation

@spydon

@spydon spydon commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Port of the v2 fixes #1621 and #1912 to v3. Closes SDK-2823, and the details decoding half of SDK-2766.

  • An error response without PostgREST JSON now raises an APIError whose message is the HTTP status phrase, details the body decoded in its Content-Type charset (None when there is no body), and hint is None.
  • The code is read from the PostgREST member of the Proxy-Status header, where PostgREST puts it for HEAD requests, and falls back to the HTTP status.
  • A success response whose body is not the JSON the query asked for keeps its own message instead of the status phrase, with the decoded body in details.

…he status phrase, Proxy-Status code and decoded body
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 90c097ea-9286-4293-aec9-cf888c72a07f
Commits

Reviewing files that changed from the base of the PR and between 16825e8 and 1b67bf7.

Files selected for processing: 5

  • src/postgrest/src/postgrest/exceptions.py
  • src/postgrest/src/postgrest/request_builder.py
  • src/postgrest/tests/_async/test_filter_request_builder_integration.py
  • src/postgrest/tests/_sync/test_filter_request_builder_integration.py
  • src/postgrest/tests/test_api_error.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@spydon
spydon merged commit 90d19c9 into main Nov 16, 2026
27 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2823-postgrest-useful-apierror-for-bodiless-and-non-json-errors branch November 16, 2026 10:27
spydon added a commit that referenced this pull request Nov 16, 2026
…tus (#2063)

Follow-up to #2061 with the review findings that missed the merge.
SDK-2823.

- A JSON error body without a `message`, as a gateway sends (`{"error":
"unauthorized"}`, `{}`), is described by the status phrase and the
Proxy-Status code, with the body in `details`, instead of "Unknown
error" with no code.
- The `charset` of `Content-Type` is parsed with the standard library
instead of a hand-written tokenizer.
- A later `PostgREST` member of `Proxy-Status` with an `error` is read
when the first one has none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant