fix(consume): guard message viewer against empty-body response crash - #3445
Open
Dave Shoup (shouples) wants to merge 1 commit into
Open
fix(consume): guard message viewer against empty-body response crash#3445Dave Shoup (shouples) wants to merge 1 commit into
Dave Shoup (shouples) wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR prevents the topic message viewer’s polling loop from silently breaking on empty-body HTTP error responses by routing response parsing through the shared extractResponseBody() helper, and adds a targeted unit test to lock in the empty-body behavior.
Changes:
- Use
extractResponseBody(error)instead oferror.response.json()in the message viewer polling error handler to avoidUnexpected end of JSON inputescaping the catch block. - Add a unit test asserting
extractResponseBody()returns""for an empty response body.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/consume.ts | Switches message-viewer polling error handling to defensive response-body extraction to avoid empty-body JSON parse crashes. |
| src/errors.test.ts | Adds coverage ensuring extractResponseBody() safely returns an empty string for empty response bodies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Dave Shoup (shouples)
marked this pull request as ready for review
August 28, 2026 20:53
Dave Shoup (shouples)
enabled auto-merge (squash)
August 28, 2026 20:53
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 of Changes
Closes #776.
The topic message viewer sometimes stops reacting to server errors while polling: the stream keeps running and no "Authentication required" / "Insufficient permissions" / "Topic not found" notification appears, while the underlying
SyntaxError: Unexpected end of JSON inputshows up in Sentry (VSCODE-EXTENSION-AJ).The cause: the error handler called
error.response.json()directly to read the response body. An empty response body makes that throw, and the throw escapes thecatchblock before it can pause the stream or notify the user.This routes the parse through the existing
extractResponseBody()helper (src/errors.ts), which already falls back to.text()when.json()fails. An empty body now resolves to""instead of throwing, so the existing status-based handling (pause and notify) runs as intended. Five other call sites already use this helper for the same reason.Click-testing instructions
Not directly click-testable (the trigger is an intermittent empty-body error response from the server). Verified via unit test instead:
npx gulp test -t "extractResponseBody".Optional: Any additional details or context that should be provided?
SyntaxErrorescapes the catch block → stream keeps running, no user notification,Unexpected end of JSON inputin Sentry.""→ status-based handling runs, stream pauses on 4xx, user is notified.error.response.json()directly and carry the same latent empty-body crash (topics.ts,kafkaClusters.ts,scaffoldUtils.ts,schemaManagement/upload.ts,loaderUtils.ts,sidecar/middlewares.ts); worth a separate cleanup pass.src/consume.tshas no co-located test file, so this is covered at theextractResponseBody()helper level rather than through the message-viewer catch block.Pull request checklist
Please check if your PR fulfills the following (if applicable):
Tests
Release notes