You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 30, 2026. It is now read-only.
A revoked or invalid API token used to crash commands with a Saloon UnauthorizedException stack trace.
This PR updates BaseCommand so it now catches it and prints a clean error that tells the user to run cloud auth, or to check LARAVEL_CLOUD_TOKEN if the token came from there.
In --json or non-interactive runs, the error is written as JSON to stderr.
This PR centralizes invalid-token handling in BaseCommand so Cloud CLI commands provide recovery guidance instead of an unauthorized-exception stack trace.
Changes:
Catches unauthorized responses and routes them through the existing error output, including JSON on stderr for headless runs.
Adds guidance for stored and environment-provided tokens.
Adds tests for command failure and recovery messages.
File
Description
tests/Feature/UnauthorizedResponseTest.php
Tests rejected-token handling and token-source guidance.
app/Commands/BaseCommand.php
Catches unauthorized responses and formats recovery messages.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A revoked saved token can incorrectly trigger advice to change a valid environment token, and command-level tests lack assertions for error content and output routing across interactive, JSON, and non-interactive modes.
Identify the credential that caused token-list authentication failure
app/Commands/BaseCommand.php:243
When the environment token is valid but a saved token is revoked, cloud auth:token --list requests organization details for both tokens (AuthToken::listTokens). A 401 from the saved-token request therefore takes this branch and tells the user to change or unset their working environment token. Please determine the source from the failing request's credential rather than the presence of the environment variable.
Assert command-level error output for JSON and non-interactive modes
tests/Feature/UnauthorizedResponseTest.php:52
This command-level test checks only the exit status, while the remaining tests invoke the message helper directly. None verifies the central output contract: a clean interactive error, or JSON on stderr with no stdout output for --json and non-interactive runs. Please add command-level output assertions for those modes so incorrect routing, serialization, or omitted remediation causes a regression failure.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human review is needed because the tests do not verify that --json and --no-interaction emit the expected JSON error to stderr while leaving stdout empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A revoked or invalid API token used to crash commands with a Saloon
UnauthorizedExceptionstack trace.This PR updates
BaseCommandso it now catches it and prints a clean error that tells the user to runcloud auth, or to checkLARAVEL_CLOUD_TOKENif the token came from there.In
--jsonor non-interactive runs, the error is written as JSON tostderr.