fix: wrong RequestException import in 7 commands + ApplicationUpdate error handling#42
Open
JoshSalway wants to merge 1 commit intolaravel:mainfrom
Open
fix: wrong RequestException import in 7 commands + ApplicationUpdate error handling#42JoshSalway wants to merge 1 commit intolaravel:mainfrom
JoshSalway wants to merge 1 commit intolaravel:mainfrom
Conversation
…to ApplicationUpdate Bug 1: 7 commands imported Illuminate\Http\Client\RequestException instead of Saloon\Exceptions\Request\RequestException. Since the Connector uses Saloon's AlwaysThrowOnErrors trait, API errors throw Saloon's exception — which was never caught. Affected commands: - ApplicationDelete - EnvironmentDelete - DatabaseClusterDelete - DomainDelete - DomainVerify - InstanceDelete - BackgroundProcessDelete Bug 2: ApplicationUpdate had no error handling for API failures. Unlike ApplicationCreate which uses loopUntilValid, update let 422/500 responses propagate as uncaught exceptions, showing raw stack traces. Added try/catch with user-friendly error messages. Both bugs were discovered while writing comprehensive test coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JoshSalway
added a commit
to JoshSalway/cloud-cli
that referenced
this pull request
Mar 16, 2026
Increases test coverage from 3/87 commands (~3%) to 43/87 (~49%), following the Laravel Forge CLI pattern of one test file per command. Commands now tested: - Auth: auth, auth:token - Application: create, get, update, delete - Environment: create, get, list, update, delete, variables - Domain: create, delete, list, verify - Database: cluster create/delete/list, database create/delete/list - Cache: create, delete, list - Bucket: create, delete, list - Instance: create, delete, list, update - WebSocket: cluster create/delete/list, application create/delete - Background Process: create, delete, list - Command: run, list Bugs documented in tests (skipped with references to PR laravel#42): - 7 commands catch wrong RequestException class (Illuminate vs Saloon) - ApplicationUpdate has no error handling for API failures - DatabaseDelete catches Throwable which swallows CommandExitException - DomainCreate missing non-interactive defaults - CacheDelete/BucketDelete missing --json option Refs laravel#41 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 16, 2026
This comment was marked as spam.
This comment was marked as spam.
This was referenced Mar 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes two bugs discovered while writing comprehensive test coverage for #41.
Closes #50
Closes #51
Bug 1: Wrong RequestException import in 7 commands
7 commands import
Illuminate\Http\Client\RequestException(Laravel HTTP client) but the CLI uses Saloon, which throwsSaloon\Exceptions\Request\RequestException. The catch blocks never match, so API errors during delete/verify operations crash with unhandled exceptions instead of showing user-friendly error messages.Affected commands:
ApplicationDeleteEnvironmentDeleteDatabaseClusterDeleteDomainDeleteDomainVerifyInstanceDeleteBackgroundProcessDeleteFix: Replace the import in all 7 files.
Bug 2: ApplicationUpdate has no error handling
ApplicationCreateusesloopUntilValidto catch validation errors, butApplicationUpdatehas no equivalent. API 422/500 responses propagate as uncaughtRequestException, showing raw stack traces to users.Fix: Added
try/catch RequestExceptionaround both the update and avatar upload API calls.How these bugs were found
While writing feature tests following the Laravel Forge CLI pattern (1 test file per command), we discovered these bugs:
ApplicationDeletewith a mocked 500 response passed without triggering the catch block — the wrong exception class was being caughtApplicationUpdatewith a mocked 422 response threw an unhandled exception instead of showing a validation errorTest plan
./vendor/bin/pest— all 31 existing tests pass./vendor/bin/phpstan analyse— 0 errorsGenerated with Claude Code