Fix TypeError when running commands on hibernating environment#109
Closed
JoshSalway wants to merge 1 commit intolaravel:mainfrom
Closed
Fix TypeError when running commands on hibernating environment#109JoshSalway wants to merge 1 commit intolaravel:mainfrom
JoshSalway wants to merge 1 commit intolaravel:mainfrom
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
DrawsThemeBoxes::box() now accepts ?string $info, coalescing to '' before passing to the parent. This prevents the TypeError crash for all callers when startedAt is null.
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
Related to #108. Blocked by API-level inconsistencies reported in #113.
This PR addresses the CLI-side TypeError but cannot fully resolve the underlying issue — the root cause is the API accepting commands on hibernating environments then immediately failing them with
started_at: null, rather than rejecting them upfront with a 422. Once #113 is addressed, this PR can be re-evaluated.DrawsThemeBoxes::box()requiresstring $info, butMonitorCommandRendererandMonitorDeploymentsRendererpass$startedAt?->toDateTimeString()which returnsnullwhenstartedAtis null. This causes:Fix
One change:
DrawsThemeBoxes::box()now accepts?string $infoand coalesces to''before passing to the parent. This protects all current and future callers.Tests
Added regression tests that reproduce the crash with null
startedAton both renderers -- verified failing before the fix and passing after.Root cause confirmed via direct API testing
We tested the API directly (
cloud.laravel.com/apiwith bearer token) to understand the exact sequence that causes this crash:POST /environments/{id}/commandson a hibernation-enabled environment returns HTTP 201 (accepted)status: "command.failure",started_at: null,failure_reason: "App is hibernating, could not locate app"nulltoDrawsThemeBoxes::box()which requiresstring $info-- triggering the TypeErrorAPI test matrix
Tested directly against
cloud.laravel.com/api. Each row was verified at least twice.Note: "Hibernating" in the table below refers to environments with
uses_hibernation=truethat reportstatus=runningbut fail commands with"App is hibernating, could not locate app". The API never returnedstatus=hibernating.GET /environments/{id}status=stoppedGET /environments/{id}status=running(nothibernating)POST /environments/{id}/commands"The environment is currently stopped."POST /environments/{id}/commands"App is hibernating, could not locate app",started_at: nullPOST /environments/{id}/commandsstarted_atpopulatedPOST /environments/{id}/startPOST /environments/{id}/start"The environment is already running."POST /environments/{id}/deploymentsThe API inconsistencies marked ❌ above have been reported in #113.
Key inconsistencies
The API knows the app is hibernating --
failure_reasonsays"App is hibernating, could not locate app"-- butGET /environments/{id}reportsstatus=running. The documentedhibernatingenum value was never observed.Commands on hibernating envs are accepted then immediately fail -- stopped environments correctly get a 422 rejection, but hibernating environments get a 201 followed by a failure with
started_at: null. This nullstarted_atis what triggers the Can't run commands whilst environment is hibernating #108 crash.POST /environments/{id}/startrejects hibernating environments with"The environment is already running."-- but the environment isn't really running (commands fail with "App is hibernating"). Users who see the Can't run commands whilst environment is hibernating #108 crash and trycloud environment:startas a workaround will get a confusing rejection.Suggested API improvements
status=hibernatingwhen instances are cold, matching the documentedEnvironmentStatusenum"The environment is currently hibernating."POST /environments/{id}/startwake a hibernating environment instead of rejecting itTest plan
startedAtwithout TypeErrorstarted_at=null-> crash)status=runningfrom the APIPOST /startrejects hibernating environments as "already running"Edit: Updated 2026-03-26 — Changed from "Fixes #108" to "Related to #108", as this PR cannot fully resolve the issue without API-level fixes (#113). Removed redundant comment.