Skip to content

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

Merged
pamelachia merged 7 commits intodevelopfrom
pamela/growth-739-cli-entitlement-aware-billing-links-for-branches-commands
Apr 7, 2026
Merged

feat(branches): entitlement-aware billing links#5040
pamelachia merged 7 commits intodevelopfrom
pamela/growth-739-cli-entitlement-aware-billing-links-for-branches-commands

Conversation

@pamelachia
Copy link
Copy Markdown
Contributor

@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

Coverage Report for CI Build 24070168818

Coverage increased (+0.07%) to 63.354%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: 36 of 36 lines across 3 files are fully covered (100%).
  • 7 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

7 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
internal/utils/git.go 5 57.14%
internal/storage/rm/rm.go 2 80.61%

Coverage Stats

Coverage Status
Relevant Lines: 14673
Covered Lines: 9296
Line Coverage: 63.35%
Coverage Strength: 6.92 hits per line

💛 - Coveralls

@pamelachia pamelachia merged commit 0d758ea into develop Apr 7, 2026
15 checks passed
@pamelachia pamelachia deleted the pamela/growth-739-cli-entitlement-aware-billing-links-for-branches-commands branch April 7, 2026 07:54
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.

3 participants