Skip to content

fix(cli): a role refusal on run register and publish says forbidden_role and why - #1146

Merged
nc9 merged 1 commit into
mainfrom
fix/cli-role-refusals
Oct 26, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/cli-role-refusals

Conversation

@nc9

@nc9 nc9 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

The cloud now enforces the organization role matrix (squirrelscan/repo#3293, and #1138 here documents it). A viewer or billing member signed in to the CLI cannot run audits in that organization, so the server refuses two calls with 403:

  • the run register (POST /v1/agent-runs/register);
  • the auto-publish (POST /v1/reports).

Both refusals come in the bare shape { error: "forbidden_role", message, role, missing_scope }.

The CLI did not handle that shape:

  • Run register: the run was silently left untracked. The warning path reads only a typed error.code from an allowlist.
  • Publish: the code read error.code and error.message off a string, so it returned a command error with no code and no message.

Now:

  • Register: a bare forbidden_role is a definitive failure. The audit prints "⚠ Run not tracked in your dashboard: Your role (viewer) in this organization does not include audits:write". Other bare-string errors, such as a 429 rate limit, still stay quiet.
  • Publish: a bare forbidden_role returns the command error forbidden_role with the server's reason, plus "Ask an owner or admin for a role that runs audits, or run with --no-publish to keep the report local". Any other bare-string error returns API_ERROR naming the status and the error.
  • The local audit and its results are unchanged.

Tests:

  • tests/lib/run-tracker.test.ts: a new case for the bare forbidden_role warning. The existing 429-stays-quiet case still passes.
  • tests/controllers/publish-role-refusal.test.ts: new, covering the role refusal and another bare-string error.
  • 56 pass across the 2 files. tsgo, oxfmt format:check and oxlint pass for apps/cli.

Docs: docs/cli/audit.mdx, under "Publishing to the dashboard", now says which roles publish and what a viewer or billing member sees; bun x [email protected] check --strict passes. CHANGELOG has an Unreleased "Fixed" entry. Skill: no change; the agent skill's role-error guidance is tracked in repo#3378.

@github-actions

Copy link
Copy Markdown
Contributor

Auto-review did not complete

The claude-review job failed before posting a review. This PR has not been auto-reviewed. Run a review manually (/review) before merging.

  • Result: success / is_error=true after 1 turns, 0 permission denial(s), $0.00
  • Job log

Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal):

Show partial review

You've hit your session limit · resets 7:40am (UTC)

@nc9
nc9 force-pushed the fix/cli-role-refusals branch from c9764c8 to 486a816 Compare October 26, 2026 06:48
@github-actions

Copy link
Copy Markdown
Contributor

Auto-review did not complete

The claude-review job failed before posting a review. This PR has not been auto-reviewed. Run a review manually (/review) before merging.

  • Result: success / is_error=true after 1 turns, 0 permission denial(s), $0.00
  • Job log

Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal):

Show partial review

You've hit your session limit · resets 7:40am (UTC)

@nc9
nc9 merged commit e934851 into main Oct 26, 2026
14 of 15 checks passed
@nc9
nc9 deleted the fix/cli-role-refusals branch October 26, 2026 07:02
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.

1 participant