feat(branches): entitlement-aware billing links#5040
Open
pamelachia wants to merge 6 commits intodevelopfrom
Open
feat(branches): entitlement-aware billing links#5040pamelachia wants to merge 6 commits intodevelopfrom
pamelachia wants to merge 6 commits intodevelopfrom
Conversation
Picks up GET /v1/organizations/{slug}/entitlements from platform#31128.
Also fixes nullable type mismatch in auth config (int -> float32)
caused by upstream spec change.
Wire SuggestUpgradeOnError into branches create and update error paths. When the API returns 402, the CLI now fetches the org's entitlements and displays a direct billing upgrade link. Create uses branching_limit (Free plan gate), update uses branching_persistent (persistent branches gate).
- Rename package-level test var to avoid collision risk - Add dashboard URL to project-lookup-failed fallback message - Add test for hasAccess:true edge case
Pull Request Test Coverage Report for Build 24036007766Details
💛 - Coveralls |
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.
Summary
When
supabase branches createorsupabase branches updatereturns a 402 (plan-gated error), the CLI now fetches the org's entitlements via the new v1 endpoint and displays a direct billing upgrade link. This replaces the generic "unexpected status 402" error with actionable guidance.Changes
GET /v1/organizations/{slug}/entitlementsfrom platform#31128internal/utils/plan_gate.gowithGetOrgSlugFromProjectRef,GetOrgBillingURL, andSuggestUpgradeOnErrorutilitiesSuggestUpgradeOnErrorintobranches create(feature key:branching_limit) andbranches update(feature key:branching_persistent) error pathsint->float32for session timebox fields in auth configTesting
Unit tests (
go test):plan_gate.go: success, 404, network error for project lookup; URL construction; 402 with gated feature, failed entitlements, failed project lookup, hasAccess:true fallback, 403/500/200 skippedbranches create402 integration test: error returned ANDCmdSuggestionset with billing linkbranches update402 integration test (persistent): error returned ANDCmdSuggestionset with billing linkgo build ./...cleanManual testing (staging,
--profile supabase-staging):branches createon a free-plan project returns 402 with correct billing upgrade link/org/<slug>/billing) resolves to the correct org billing pageOnly
createandupdateare wired because the platform API only returns 402 from those two branch endpoints. All other operations (list, get, delete, pause, unpause, disable) are never plan-gated.Linear