[BUG] Webview streaming parser throws "Unhandled case: [object Object]" on unrecognized stream event / content_block_delta types (not forward-compatible)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
## Summary
The VS Code extension's webview bundles a streaming-response parser whose switch
statements over Anthropic API stream event types and content_block_delta types use a
throwing default: branch. When the API streams any event/delta type the bundled
parser doesn't recognize, it throws Unhandled case: [object Object], which surfaces as
a persistent error banner in the Claude panel and halts the session. The extension
breaks whenever the API introduces a new streaming type, until the extension is updated.
## Environment
- Extension: Claude Code for VS Code v2.1.141 (latest available at time of report)
- VS Code: stable, build 0958016b2a, Windows 11
- CLI: claude 2.1.141
- Model in use: claude-opus-4-7[1m]
## Impact
Constant, unrecoverable "Unhandled case: [object Object]" banner in the panel. Full VS
Code restart, extension reinstall, and disabling other extensions do not help. The agent
process itself stays healthy — it keeps streaming/responding in the output logs — only
the webview's bundled parser crashes.
## Root cause
In webview/index.js, two switch statements in the stream assembler use QB1 (an
assert-never helper that throws) as their default: branch:
XB1.prototype.processStreamEvent— switch over stream event$.type
(message_start, message_delta, content_block_start, content_block_delta,
content_block_stop, message_stop) → default: QB1($)
b20(...)— switch overcontent_block_deltadeltaJ.type
(text_delta, citations_delta, input_json_delta, thinking_delta,
signature_delta, compaction_delta) → default: QB1(J)
QB1 is function QB1($,Z){throw Error(Z ?? Unhandled case: ${$})}. Because $/J
is an object, the message renders as Unhandled case: [object Object].
Any new stream event type or content_block_delta type added server-side will hit
default: and throw, breaking all streaming until the extension ships an update. The
bundled CLI agent's own parser does not have this problem and keeps working — only the
webview copy throws.
What Should Happen?
Ideally, no errors in the VS IDE, and a working Claude code.
## Expected behavior
The streaming parser should be forward-compatible: unknown stream event types and unknown
content_block_delta types should be ignored (default: break) rather than throwing.
Error Messages/Logs
Unhandled case: [object Object]
View output logs · Troubleshooting resources
Steps to Reproduce
Use the extension against an API/model that emits a stream event or content_block_delta
type newer than the cases enumerated in the bundled parser. Every streamed response then
throws and the panel becomes unusable.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.141
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
## Suggested fix
Change the default: branches in processStreamEvent and b20 from the throwing
QB1(...) to a no-op (default: break), or log-and-ignore. Reserve assert-never for
genuinely closed unions, not for parsing data from an evolving wire protocol.
## Workaround
Patching the two default: branches in webview/index.js to default: break and fully
restarting VS Code resolves it (until the next extension update overwrites the file).
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗