Conversation
The relay signals infrastructure failures with x-relay-error, including on non-2xx statuses. invoke() looked at x-relay-header after raise_for_status, so FunctionsRelayError never fired for real relay failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
Fixes #1637
invoke()is supposed to raiseFunctionsRelayErrorwhen the Supabase relay cannot reach the Edge Function. Two things prevent that:x-relay-header. The relay, supabase-js, supabase-swift, and supabase_flutter all usex-relay-error._requestcallsraise_for_status()before any relay-header check. Relay failures are non-2xx (supabase-swift#1112), so they becomeFunctionsHttpErroreven if the header name were corrected.The existing tests mock
x-relay-headeron a 200, so they pass whileexcept FunctionsRelayErroris dead in production. The generated sync client has the same code.What is the new behavior?
_requestchecksx-relay-error == "true"beforeraise_for_status()and raisesFunctionsRelayErrorwith the response status, matching supabase-js:A function-side 4xx/5xx without that header is still
FunctionsHttpError. Publicinvoke()arguments are unchanged.Open PRs #1576 and #1600 touch nearby error-body parsing in the same files but still read
x-relay-header; this change is the wire-format/order fix.Tests
test_invoke_with_relay_errornow sends the realx-relay-errorheader. Newtest_invoke_relay_error_on_non_2xx_statusreturns 546 plusx-relay-error: trueand assertsFunctionsRelayError(notFunctionsHttpError). Both fail onmain@ bb7ecc5 and pass here, async and sync.Validation
main(DID NOT RAISE /FunctionsHttpError), green after: 4 passed.uv run --package supabase_functions pytest: 67 passed, 1 skipped (test_strenum_import_python_310_and_belowon 3.13).uv run --package supabase_functions mypy src/supabase_functions tests: no issues in 16 source files.uv run ruff check/uv run ruff format --checkonsrc/functions: clean.git diff --check: clean.Functions tests are unit tests with httpx mocks and do not need Docker or the Supabase CLI.