Skip to content

feat(plan-gate): wire billing links into remaining plan-gated commands#5066

Open
pamelachia wants to merge 7 commits intodevelopfrom
pamela/growth-740-cli-wire-billing-links-into-remaining-plan-gated-commands
Open

feat(plan-gate): wire billing links into remaining plan-gated commands#5066
pamelachia wants to merge 7 commits intodevelopfrom
pamela/growth-740-cli-wire-billing-links-into-remaining-plan-gated-commands

Conversation

@pamelachia
Copy link
Copy Markdown
Contributor

Summary

Extends SuggestUpgradeOnError to check org entitlements on any non-2xx API response (not just 402), then shows a billing upgrade link only when the entitlements API confirms hasAccess == false. Wires this into SSO and vanity-subdomain commands.

Previously, only branches create and branches update had billing links. Many plan-gated endpoints return 400 or 404 instead of 402, so the old 402-only check missed them. The new approach catches all error codes while preventing false positives via entitlements confirmation.

Changes

  • Refactor SuggestUpgradeOnError to trigger on any non-2xx, confirm gate via entitlements API before showing billing link
  • Remove generic fallback messages ("may require a plan upgrade") that caused false positives
  • Wire sso create/update/list/remove with auth.saml_2 entitlement check
  • Wire vanity-subdomains activate/check with vanity_subdomain entitlement check
  • Update existing tests to handle the new entitlements probe on non-2xx responses

Testing

Tested locally:

  • go build ./... passes
  • All affected package tests pass (branches, sso, vanity_subdomains, utils)
  • Existing 402 behavior preserved for branches create/update
  • SSO commands: 404 from GoTrue + gated entitlement shows billing link
  • SSO commands: 404 from GoTrue + ungated entitlement shows existing "enable through dashboard" message
  • Vanity subdomain: 400 + gated entitlement shows billing link
  • Non-2xx errors with failed entitlements lookup show no suggestion (no false positives)
  • 2xx responses skip the check entirely

Descoped (intentionally)

  • custom_domain, pitr.available_variants: addon-gated, not plan-gated (GROWTH-741)
  • function.max_count: hasAccess: true for all plans (numeric limit only)
  • network-restrictions: not plan-gated (infra flag)
  • branches delete: intentionally not gated

Linear

  • fixes GROWTH-740

…k when confirmed gated

Previously SuggestUpgradeOnError only triggered on 402. Many plan-gated
endpoints return 400 or 404 instead. Now checks entitlements on any
non-2xx and only sets CmdSuggestion when hasAccess is confirmed false,
preventing false positives.
Aligns variable name with the new semantics: SuggestUpgradeOnError
now checks entitlements on any non-2xx, not just 402.
Check org entitlements for auth.saml_2 on any non-2xx response from
SSO provider endpoints. Shows billing upgrade link when the feature
is confirmed gated, before falling through to existing error handling.
…ands when plan-gated

Check org entitlements for vanity_subdomain on any non-2xx response.
The platform API returns 400 when vanity subdomains are not available
on the org's plan; the entitlements check confirms the gate before
showing a billing upgrade link.
@pamelachia pamelachia requested a review from a team as a code owner April 11, 2026 13:48
@pamelachia pamelachia self-assigned this Apr 11, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 11, 2026

Coverage Report for CI Build 24284111986

Coverage decreased (-0.3%) to 63.55%

Details

  • Coverage decreased (-0.3%) from the base build.
  • Patch coverage: 58 uncovered changes across 6 files (16 of 74 lines covered, 21.62%).
  • 9 coverage regressions across 5 files.

Uncovered Changes

File Changed Covered %
internal/sso/update/update.go 13 1 7.69%
internal/sso/create/create.go 10 0 0.0%
internal/sso/list/list.go 10 1 10.0%
internal/sso/remove/remove.go 10 1 10.0%
internal/vanity_subdomains/activate/activate.go 10 1 10.0%
internal/vanity_subdomains/check/check.go 10 1 10.0%

Coverage Regressions

9 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
internal/utils/git.go 5 57.14%
internal/sso/create/create.go 1 0.0%
internal/sso/list/list.go 1 40.74%
internal/sso/remove/remove.go 1 41.94%
internal/sso/update/update.go 1 47.78%

Coverage Stats

Coverage Status
Relevant Lines: 15413
Covered Lines: 9795
Line Coverage: 63.55%
Coverage Strength: 7.0 hits per line

💛 - Coveralls

…heck to 4xx

Two fixes:
- branches/update passed flags.ProjectRef instead of the local
  projectRef resolved from the branch ID, causing entitlements to
  look up the wrong org
- Restrict SuggestUpgradeOnError to 4xx client errors only (skip 2xx
  success and 5xx server errors) to avoid unnecessary API calls on
  server outages
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