fix(sim-cli): report an embedded SimApiError with its own exit code - #8462
Merged
Merged
Conversation
The embedded renderer returned 1 for every SimApiError, so an operation wait that timed out (exit 4) or needs configuration (exit 3) read as a generic failure in-process while the installed CLI reported the real status. Return error.exitCode, as the terminal renderer does.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
…ner speed The test gave the wait 10 ms of real time, so a slow runner could reach the deadline before the first status check and exit 4 without printing the receipt. The clock now advances only when the stubbed status is served, so the wait times out only after it has a receipt to print.
Collaborator
Author
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This branch was previously deployed
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
The embedded CLI now reports a
SimApiErrorwith that error's own exit code, as the installed CLI already does.renderEmbeddedErrorinpackages/sim-cli/src/embed.tsreturned1for everySimApiErrorand ignorederror.exitCode. The terminal renderer (terminal.ts) returns it. So when a workspace operation wait timed out (exit 4,OPERATION_WAIT_TIMEOUT) or the operation needed destination configuration (exit 3,REQUIRES_CONFIGURATION), an in-process run reported a generic failure. The installed CLI reported the real outcome. Now both report the same code. The stderr text is unchanged.Exit codes this surfaces
SimApiErrors that carry a code other than 1 are the workspace-operation outcomes inworkspace-operation-wait.ts:workflows runs wait(0/1/2/3/4) already reached embedded callers through the embed context and are unaffected.Consumers
Every caller of
runEmbeddedClibranches only on zero vs non-zero:sim_clitool handler;A 3 or 4 that used to arrive as 1 is still a failure to each of them. A caller that wants to tell the outcomes apart, such as a wait that continues after "still running", can now read the real code.
Test plan
OPERATION_WAIT_TIMEOUTon stderr. It failed with exit 1 before the fix and passes after.bun run lint,type-check(sim-cli and apps/sim),bun run check:audits, and the apps/sim agent-CLI and tool-handler suites.Follow-ups (not in this PR)
Detached synchronous runs. A
workflows runthat submits and then polls in bounded slices, so no single request stays open for the whole run. It is not built onasync: true, because a queued run is a different run from a synchronous one:It needs:
The CLI would then submit with that option, poll with the loop
workflows runs waituses, print exactly what a synchronous run prints when it settles, and on timeout print the run record with exit 4.Block attribution on the v2 run resource. The polled run resource reclassifies a failed run's stored error string, so it reports no failing block, and a timeout or usage-limit failure known only from its HTTP status is not recognized. Recording the classification (code, plus the block when one is to blame) with the log at error finalization, and applying it on read, would make it match the synchronous response. That change also needs:
code,blockId/blockName/blockType, and the runerror(runs logged earlier and the resume response keep reclassifying);