fix: EPIPE crash on stdin.write and add lenient JSON parsing for Claude output#17
Open
madhavikodale wants to merge 2 commits into
Open
fix: EPIPE crash on stdin.write and add lenient JSON parsing for Claude output#17madhavikodale wants to merge 2 commits into
madhavikodale wants to merge 2 commits into
Conversation
…de output
- Add parseJsonLenient() utility for extracting JSON from mixed text/code blocks
- Add extractResultFromMixedOutput() to find result objects in Claude output
- Fix EPIPE crash by using stdin.on('error') + callback-style write()
- Treat exit-code-0 + parse failure as inferred success in claude-local
Fixes OpenScanAI#16
…rsing - Add parseJsonLenient() tests in adapter-utils (9 cases) - Add parseClaudeStreamJson() tests in claude-local (8 cases) - Add runChildProcess EPIPE handling tests (2 cases) - Update CHANGELOGs for adapter-utils and claude-local - All 61 targeted tests pass; pnpm -r typecheck clean
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.
Thinking Path
What Changed
parseJsonLenient()utility inadapter-utils/src/server-utils.tsthat attempts direct parse, then code-block extraction, then progressive substring parsingextractResultFromMixedOutput()inclaude-local/src/server/parse.tsto find JSON objects with"type": "result"inside mixed textparseClaudeStreamJson()to use lenient parsing as fallback when line-by-line parsing finds no resultrunChildProcess(): replaced try/catch withstdin.on("error", ...)listener and callback-stylestdin.write(chunk, cb)parseJsonLenient()(9 cases),parseClaudeStreamJson()(8 cases), and EPIPE handling (2 cases)adapter-utilsandclaude-localVerification
Manual verification:
pnpm devRisks
inferredSuccessflag may mask genuine failures if Claude exits 0 with garbage output; monitored viaresultJson.inferredSuccessModel Used
Checklist
If this change affects the UI, I have included before/after screenshots(N/A — no UI changes)