Skip to content

fix(cli): stop false plan-upgrade on channel set and skip open() in CI - #3151

Merged
riderx merged 1 commit into
mainfrom
cursor/fix-cli-false-plan-upgrade-967f
Aug 21, 2026
Merged

riderx merged 1 commit into
mainfrom
cursor/fix-cli-false-plan-upgrade-967f

Conversation

@riderx

@riderx riderx commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

Summary (AI generated)

  • Removed the kitchen-sink checkPlanValid call from channel set / promote so channel updates no longer fail with billing copy when the org plan is healthy.
  • Added canOpenExternalUrl / openExternalUrl guards so plan-upgrade prompts never spawn xdg-open in CI, non-TTY, or headless Linux sessions; ENOENT is swallowed.
  • Updated checkPlanValid / checkPlanValidUpload to distinguish app-scoped plan RPC RBAC denials from real billing limits and report a permission error instead of “upgrade your plan”.
  • Extended CLI plan-validation tests for RBAC vs billing, CI browser guard, and channel-set source checks.

Motivation (AI generated)

SuperFrete (pro.payit.freight) runs Capgo in Bitbucket Pipelines. They can channel list, but channel 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: checkPlanValid calls is_allowed_action_org_action with build_time and other meters; that RPC returns false when app.read RBAC fails, and the CLI treated any false as billing. The follow-on unguarded open() then crashed headless CI with spawn 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-validation
  • CI green on PR

Generated with AI

Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved metered-plan validation to distinguish billing restrictions from app-specific permission denials.
    • Channel updates no longer fail due to unrelated plan checks.
    • Permission-specific error messages are now reported more accurately.
  • Improvements

    • Upgrade links open safely only when supported by the environment.
    • Browser launches are skipped in CI, non-interactive, and headless environments.

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>
@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e43342ca-cc86-445f-8a26-8b86999fed4a

📥 Commits

Reviewing files that changed from the base of the PR and between 8218347 and 21685a6.

📒 Files selected for processing (3)
  • cli/src/channel/set.ts
  • cli/src/utils.ts
  • cli/test/test-plan-validation.mjs

📝 Walkthrough

Walkthrough

The 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.

Changes

CLI plan flow

Layer / File(s) Summary
Guarded external URL handling
cli/src/utils.ts, cli/test/test-plan-validation.mjs
The CLI skips browser launches in CI, non-interactive terminals, and headless Linux. It ignores missing xdg-open executables and tests the supported environment cases.
Metered-plan validation results
cli/src/utils.ts, cli/test/test-plan-validation.mjs
Metered-plan checks return allowed, billing_denied, or permission_denied. Plan validation reports permission-specific errors and uses guarded upgrade URL handling. Tests cover organization-level and app-scoped access.
Channel setup decoupling
cli/src/channel/set.ts, cli/test/test-plan-validation.mjs
Channel setup no longer imports or invokes checkPlanValid after resolving the organization ID. A source assertion verifies the removal.

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
Loading

Suggested reviewers: wcaleniewolny

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@codspeed

codspeed Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing cursor/fix-cli-false-plan-upgrade-967f (21685a6) with main (8218347)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@sonarqubecloud

Copy link
Copy Markdown

@riderx
riderx marked this pull request as ready for review August 21, 2026 15:18
@riderx
riderx merged commit a0c9f76 into main Aug 21, 2026
63 of 68 checks passed
@riderx
riderx deleted the cursor/fix-cli-false-plan-upgrade-967f branch August 21, 2026 15:19

This branch was previously deployed

1 inactive deployment
deepsec-pr — 21685a67 Deployed Aug 21, 2026 by riderx via Scan PR changes #4734
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