Repository navigation
fix(cli): stop false plan-upgrade on channel set and skip open() in CI - #3151
Conversation
Remove the kitchen-sink plan check from channel set/promote so RBAC-only API keys are not blocked with billing copy. Guard plan-upgrade browser opens behind canOpenExternalUrl (CI, no TTY, headless Linux) and swallow xdg-open ENOENT. Distinguish app-scoped plan RPC RBAC denials from real billing limits in checkPlanValid/checkPlanValidUpload. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe CLI adds guarded external URL handling, classifies metered-plan access results, reports permission-specific validation errors, and removes plan validation from channel setup. Tests cover environment checks, RBAC outcomes, upgrade URL handling, and channel behavior. ChangesCLI plan flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as CLI plan validation
participant Supabase
participant URLHelper as openExternalUrl
participant Browser
CLI->>Supabase: Resolve organization and app-scoped plan access
Supabase-->>CLI: Return allowed, billing_denied, or permission_denied
alt billing_denied
CLI->>URLHelper: Open upgrade URL
URLHelper->>Browser: Launch browser when environment permits
else permission_denied
CLI-->>CLI: Report permission-specific error
end
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
|



Summary (AI generated)
checkPlanValidcall fromchannel set/ promote so channel updates no longer fail with billing copy when the org plan is healthy.canOpenExternalUrl/openExternalUrlguards so plan-upgrade prompts never spawnxdg-openin CI, non-TTY, or headless Linux sessions; ENOENT is swallowed.checkPlanValid/checkPlanValidUploadto distinguish app-scoped plan RPC RBAC denials from real billing limits and report a permission error instead of “upgrade your plan”.Motivation (AI generated)
SuperFrete (
pro.payit.freight) runs Capgo in Bitbucket Pipelines. They canchannel list, butchannel set/ promote failed with “Plan upgrade required” even though Capgo-EU prod billing is healthy (is_good_plan, Stripe succeeded, no quota exceeded). Root cause:checkPlanValidcallsis_allowed_action_org_actionwithbuild_timeand other meters; that RPC returnsfalsewhenapp.readRBAC fails, and the CLI treated anyfalseas billing. The follow-on unguardedopen()then crashed headless CI withspawn xdg-open ENOENT.Business Impact (AI generated)
Paying customers can promote bundles in CI/CD without false billing blocks or Node crashes. This restores a core OTA deployment path for API-key-based pipelines that have channel promote permissions but not app billing read scope.
Test Plan (AI generated)
bun run lint(cli)bun run build(cli)bun run test:plan-validationGenerated with AI
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Improvements