Skip to content

fix: explain Robots permission recovery in the CLI - #80

Merged
walkerfrankenberg merged 1 commit into
mainfrom
codex/ait-601-permission-errors
Oct 30, 2026
Merged

walkerfrankenberg merged 1 commit into
mainfrom
codex/ait-601-permission-errors

Conversation

@walkerfrankenberg

@walkerfrankenberg walkerfrankenberg commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Robots 403 insufficient_scope responses fall through to generic CLI error formatting, losing structured permission and recovery details for agents. Preserve the API error and give recovery instructions for the credential actually in use.

What was changed

  • Handle only Robots SDK permission errors with the explicit insufficient_scope type.
  • Preserve the original API response and messages in JSON/agent output; explain token replacement and environment-variable precedence, or OAuth reauthorization and narrowed grants.
  • Cover Basic/OAuth recovery, agent/JSON output, local credential lookup failure, and unrelated quota, disabled-account, and other-product errors.
  • Validation: full CLI tests, Biome checks, typecheck, and build pass. Existing skipped/todo tests remain.

Suggested review order

  1. src/lib/errors.ts.
  2. src/lib/errors.test.ts.

Note

Low Risk
Localized CLI error-handling for Robots permission responses; no auth or API behavior changes beyond clearer messages and JSON shape for one error type.

Overview
Robots insufficient_scope errors now get a dedicated path in handleCommandError instead of generic CLI formatting.

When the Robots API returns a PermissionDeniedError with error.type === 'insufficient_scope', the CLI keeps the server messages and emits structured JSON (error, messages, api_response) for agent/JSON modes. It also appends recovery text based on how the user is authenticated: dashboard token replacement (including MUX_TOKEN_ID/MUX_TOKEN_SECRET precedence), OAuth re-login with MUX_OAUTH_SCOPES guidance, or a fallback when local credentials cannot be loaded.

The special case is narrow: only Robots + explicit insufficient_scope on permission errors (not other 403 types, wrong status codes, or non-robots command groups). Tests cover Basic vs Bearer auth, credential lookup failure, agent/JSON output, and cases that must not be relabeled.

Reviewed by Cursor Bugbot for commit 8b56a3c. Bugbot is set up for automated code reviews on this repo. Configure here.

@walkerfrankenberg
walkerfrankenberg merged commit 9ff41f4 into main Oct 30, 2026
8 checks passed
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