fix: wait for branch project refs via the branches endpoint#348
Open
sincraianul wants to merge 1 commit into
Open
fix: wait for branch project refs via the branches endpoint#348sincraianul wants to merge 1 commit into
sincraianul wants to merge 1 commit into
Conversation
supabase_settings with a branch ref fails on create/update since v1.7.0:
waitForProjectActive polls GET /v1/projects/{ref}, which returns 404 for
branch refs, and any non-200 aborts the retry loop immediately.
Fall back to GET /v1/branches/{branch_id_or_ref} on 404. Its status field
shares the project status vocabulary, so it feeds the same state machine.
Refs unknown to both endpoints still fail with the original error.
Fixes supabase#345
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2 tasks
JEETDESAI25
self-requested a review
July 22, 2026 19:01
JEETDESAI25
approved these changes
Jul 23, 2026
JEETDESAI25
left a comment
Collaborator
There was a problem hiding this comment.
Hey @sincraianul, Thank you for the fix and the thorough regression coverage.
This looks good to me. Falling back to the branch endpoint only when the project lookup returns 404 fixes settings for preview branch refs while preserving the existing behavior for regular projects. The branch detail status uses the same status vocabulary, so reusing the existing readiness state machine is sound.
No blockers from me @savme.
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 — fixes #345.
Since v1.7.0,
supabase_settingsfails on Create/Update whenproject_refis a branch ref (e.g.supabase_branch.x.database.id):#272 added a
waitForProjectActivegate that pollsGET /v1/projects/{ref}and treats any non-200 as fatal (aRefresherror abortsretry.StateChangeConfimmediately — the "timeout" wording is misleading; it fails on the first poll). Branch refs are not served by that endpoint, so the gate broke the settings-on-branch pattern that worked through v1.6.2 and that Supabase's own example uses (supabase-action-examplepreview.tf).Verified against the live Management API with a branch ref (matching the reporter's findings in #345):
GET /v1/projects/{branch-ref}GET /v1/branches/{branch-ref}status: ACTIVE_HEALTHYGET /v1/projects/{branch-ref}/healthGET /v1/projects/{branch-ref}/postgrestSo only
waitForProjectActiveneeds changing — the config and health endpoints all accept branch refs, meaningwaitForServicesActive/waitForAuthServiceActivealready work.What is the current behavior?
waitForProjectActiveaborts on the projects endpoint's 404, sosupabase_settings(and anything else gated on it) can never apply against a branch ref. Reported in #345.What is the new behavior?
On 404 from
GET /v1/projects/{ref},waitForProjectActivefalls back toGET /v1/branches/{branch_id_or_ref}(V1GetABranchConfigWithResponse).BranchDetailResponse.Statusshares the project status vocabulary (ACTIVE_HEALTHY,COMING_UP,INIT_FAILED, …), so it feeds the existing state machine unchanged — including fail-fast on terminal states and polling on transient ones. Refs unknown to both endpoints still fail with the original error, so the race #272 fixed (#239) stays fixed for real projects.Tests:
TestAccSettingsResource_BranchRefmocking the full 404→branches-endpoint flow for both create and update ofsupabase_settings.Additional context
The status vocabulary trap for anyone touching this later: the branches list endpoint (
GET /v1/projects/{ref}/branches) reports a workflow-stylestatus(FUNCTIONS_DEPLOYED, …) plus a separatepreview_project_status; only the branch detail endpoint used here reports project-style status directly.🤖 Generated with Claude Code