Skip to content

feat(branches): entitlement-aware billing links#5040

Open
pamelachia wants to merge 6 commits intodevelopfrom
pamela/growth-739-cli-entitlement-aware-billing-links-for-branches-commands
Open

feat(branches): entitlement-aware billing links#5040
pamelachia wants to merge 6 commits intodevelopfrom
pamela/growth-739-cli-entitlement-aware-billing-links-for-branches-commands

Conversation

@pamelachia
Copy link
Copy Markdown

@pamelachia pamelachia commented Apr 6, 2026

Summary

When supabase branches create or supabase branches update returns 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

  • Regenerate API client from staging spec, picking up GET /v1/organizations/{slug}/entitlements from platform#31128
  • Add internal/utils/plan_gate.go with GetOrgSlugFromProjectRef, GetOrgBillingURL, and SuggestUpgradeOnError utilities
  • Wire SuggestUpgradeOnError into branches create (feature key: branching_limit) and branches update (feature key: branching_persistent) error paths
  • Fix upstream spec change: int -> float32 for session timebox fields in auth config

Testing

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 skipped
  • branches create 402 integration test: error returned AND CmdSuggestion set with billing link
  • branches update 402 integration test (persistent): error returned AND CmdSuggestion set with billing link
  • All existing branch tests pass (no regressions across 8 subcommands)
  • Full go build ./... clean

Manual testing (staging, --profile supabase-staging):

  • branches create on a free-plan project returns 402 with correct billing upgrade link
  • Billing URL (/org/<slug>/billing) resolves to the correct org billing page

Only create and update are 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

  • fixes GROWTH-739

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
@pamelachia pamelachia requested a review from a team as a code owner April 6, 2026 14:32
@pamelachia pamelachia self-assigned this Apr 6, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 6, 2026

Pull Request Test Coverage Report for Build 24036007766

Details

  • 36 of 36 (100.0%) changed or added relevant lines in 3 files are covered.
  • 8 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.05%) to 63.334%

Files with Coverage Reduction New Missed Lines %
internal/debug/postgres.go 3 66.09%
internal/utils/git.go 5 57.14%
Totals Coverage Status
Change from base Build 24034420348: 0.05%
Covered Lines: 9293
Relevant Lines: 14673

💛 - Coveralls

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.

2 participants