fix: ZodError in session processor for tool error status #150
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 the
ZodError("No matching discriminator") that crashes the session when a tool execution fails or is aborted.7748404changedstatus: 'error'tostatus: 'failed'inprocessor.ts, but the Zod schemaToolStateErrordefines the valid status asz.literal('error'). This mismatch causes thez.discriminatedUnion('status', [...])validation to reject the data whenSession.updatePart()is called.status: 'error'in all 3 places inprocessor.tsand 1 place inevent-handler.js, aligning with the Zod schema and upstream OpenCode.status: 'error'consistently.Changes
js/src/session/processor.ts: Change'failed'→'error'in tool-error handler and cleanup loop (3 changes)js/src/cli/event-handler.js: Change'failed'→'error'in tool state check (1 change)docs/case-studies/issue-149/: Full case study with timeline reconstruction, root cause analysis, and incident logjs/.changeset/fix-tool-state-zod-error.md: Changeset for patch releaseFixes #149
Test plan
bun test- session-usage, json-standard-unit, socket-retry, timeout-retry, stream-timeout)npm run check)This PR was created automatically by the AI issue solver