fix(api): guard /v1/install catch against non-JSON Error.message (PKT-530 / PKT-472 regression) - #441
Open
bugsyhewitt wants to merge 1 commit into
Open
Conversation
…-530 / PKT-472 regression) Re-applies the PKT-472 Part B wrap-fix that was silently reverted by commit 37be068 (PKT-476). Wraps JSON.parse((e as Error).message) in server.ts:238 with a try/catch that returns 400 INSTALL_HANDLER_ERROR on parse failure instead of letting a SyntaxError escape to the outer 500 catch. Adds a regression test (installState.installThrow=true path) to lock the fix against future reversion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
37be0689(PKT-476, Aug 1 23:51 EDT)JSON.parse((e as Error).message)atserver.ts:238in a try/catch; on parse failure returns400 INSTALL_HANDLER_ERRORwith a stable structured body instead of letting aSyntaxErrorescape to the outer 500 catchinstallState.installThrow = truepath ints-api-server-route-handler-defensive-paths.test.ts) to lock the fix against future reversionDefect class
shipped-then-reverted-via-subsequent-commit(same class as prior regressions in the decisions-log). PKT-472 Part B was correctly fixed and PR-diff'd in PR #405, but PKT-476 (37be0689) touched the surrounding region and restored the unwrapped line. This is the disciplinary gap PKT-530 closes: the regression test now pins the boundary.Test plan
expected 500 to be 400+SyntaxError: Unexpected token 'm'logged (exact regression from packet §3)pnpm exec vitest run→ 138 files passed | 2 skipped (140 total), 2162 tests passed | 46 skippedPYTHONPATH=src pytest→ 1206 passed, 125 skipped, 6 warningsPOST /v1/installwith valid credentials returns400 {"error":{"code":"INSTALL_HANDLER_ERROR","message":"Install handler failed; see server logs for details.","details":{}}}— not 500Files changed
src/alienclaw/api/server.ts— +12 lines (inner try/catch wrap around JSON.parse)test/api/ts-api-server-route-handler-defensive-paths.test.ts— +10 lines (regression test, inserted before the stats-override block)🤖 Generated with Claude Code