fix(discord): guard JSON.parse against malformed API response bodies#97889
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 1, 2026, 8:28 PM ET / 00:28 UTC. Summary PR surface: Source +7, Tests +18. Total +25 across 2 files. Reproducibility: yes. A custom fetcher returning malformed HTTP 200 JSON through Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Next step before merge
Security Review detailsBest possible solution: Land the narrow Do we have a high-confidence way to reproduce the issue? Yes. A custom fetcher returning malformed HTTP 200 JSON through Is this the best way to solve the issue? Yes. Catching the parse failure inside AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3558391a75fd. Label changesLabel justifications:
Evidence reviewedPR surface: Source +7, Tests +18. Total +25 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
29e4b74 to
73da0d9
Compare
73da0d9 to
853e64a
Compare
|
@clawsweeper automerge |
|
🦞🧹
Draft PRs stay fix-only until GitHub marks them ready for review. Pause with Automerge progress:
|
853e64a to
9dadf44
Compare
Wrap JSON.parse(text) in requestDiscord with try/catch to prevent a malformed Discord API response body from throwing an unhandled SyntaxError and crashing the process. On parse failure, throw a DiscordApiError with a descriptive message so the caller can handle it gracefully. Co-Authored-By: Claude <[email protected]> Signed-off-by: lsr911 <[email protected]>
Signed-off-by: lsr911 <[email protected]>
Signed-off-by: lsr911 <[email protected]>
Signed-off-by: lsr911 <[email protected]>
8911d25 to
3573b45
Compare
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
Maintainer review complete on exact head Land-ready proof:
The ordinary local prepare path was intentionally stopped when pnpm asked to remove and reinstall all workspace module directories from the symlinked worktree. That was a dependency-layout prompt, not a patch failure; no shared modules were modified. The final merge-base diff remains the narrow two-file Discord response guard. Valid JSON, blank bodies, response-size limits, and HTTP 429 retry behavior remain unchanged; malformed successful JSON now uses the owned non-retryable Discord error type. |
|
Merged via squash.
|
* origin/main: test(gateway): isolate live release agent state test(plugins): repair prerelease validation fixtures fix(discord): guard JSON.parse against malformed API response bodies (#97889) fix(codex): preserve app approvals in side forks (#98812) fix(agents): don't inject A2A turns into isolated-cron sessions_send (#92257) (#92283) fix(browser): guard setDeep against empty keys array (#98138) docs(telegram): move maintainer decisions into scoped AGENTS.md fix(ios): generate light app store screenshots only fix(gateway): distinguish reachable gateway from failed status probe (#98183)
…penclaw#97889) * fix(discord): guard JSON.parse against malformed API response bodies Wrap JSON.parse(text) in requestDiscord with try/catch to prevent a malformed Discord API response body from throwing an unhandled SyntaxError and crashing the process. On parse failure, throw a DiscordApiError with a descriptive message so the caller can handle it gracefully. Co-Authored-By: Claude <[email protected]> Signed-off-by: lsr911 <[email protected]> * fix(clawsweeper): address review for automerge-openclaw-openclaw-97889 (validation-1) * chore: trigger CI re-run for flaky checks-node-compact-small-whole-2 Signed-off-by: lsr911 <[email protected]> * chore: trigger CI re-run for flaky runtime-inventory-drift-check Signed-off-by: lsr911 <[email protected]> * chore: trigger CI re-run for flaky checks-node-compact-large-whole-1 Signed-off-by: lsr911 <[email protected]> * fix(discord): guard JSON.parse against malformed API response bodies * fix(discord): guard JSON.parse against malformed API response bodies --------- Signed-off-by: lsr911 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
…penclaw#97889) * fix(discord): guard JSON.parse against malformed API response bodies Wrap JSON.parse(text) in requestDiscord with try/catch to prevent a malformed Discord API response body from throwing an unhandled SyntaxError and crashing the process. On parse failure, throw a DiscordApiError with a descriptive message so the caller can handle it gracefully. Co-Authored-By: Claude <[email protected]> Signed-off-by: lsr911 <[email protected]> * fix(clawsweeper): address review for automerge-openclaw-openclaw-97889 (validation-1) * chore: trigger CI re-run for flaky checks-node-compact-small-whole-2 Signed-off-by: lsr911 <[email protected]> * chore: trigger CI re-run for flaky runtime-inventory-drift-check Signed-off-by: lsr911 <[email protected]> * chore: trigger CI re-run for flaky checks-node-compact-large-whole-1 Signed-off-by: lsr911 <[email protected]> * fix(discord): guard JSON.parse against malformed API response bodies * fix(discord): guard JSON.parse against malformed API response bodies --------- Signed-off-by: lsr911 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
…penclaw#97889) * fix(discord): guard JSON.parse against malformed API response bodies Wrap JSON.parse(text) in requestDiscord with try/catch to prevent a malformed Discord API response body from throwing an unhandled SyntaxError and crashing the process. On parse failure, throw a DiscordApiError with a descriptive message so the caller can handle it gracefully. Co-Authored-By: Claude <[email protected]> Signed-off-by: lsr911 <[email protected]> * fix(clawsweeper): address review for automerge-openclaw-openclaw-97889 (validation-1) * chore: trigger CI re-run for flaky checks-node-compact-small-whole-2 Signed-off-by: lsr911 <[email protected]> * chore: trigger CI re-run for flaky runtime-inventory-drift-check Signed-off-by: lsr911 <[email protected]> * chore: trigger CI re-run for flaky checks-node-compact-large-whole-1 Signed-off-by: lsr911 <[email protected]> * fix(discord): guard JSON.parse against malformed API response bodies * fix(discord): guard JSON.parse against malformed API response bodies --------- Signed-off-by: lsr911 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
What Problem This Solves
extensions/discord/src/api.ts:198callsJSON.parse(text)on the Discord API response body without try/catch. Malformed JSON → unhandled SyntaxError → process crash.Changes
extensions/discord/src/api.ts: wrapJSON.parse(text)in try/catch →DiscordApiError("malformed JSON", 0)extensions/discord/src/api.test.ts: test verifying malformed JSON →DiscordApiErrortest/_proof_discord_json_guard.mts: v3 — callsrequestDiscordwith custom fetcher returning malformed JSON, exercises actual changed code pathLabel: bugfix | merge-risk: 🟢 minimal | AI-assisted
Evidence
Real HTTP proof — calls requestDiscord (L2)
Unit test
Fix history
catch (cause)→ lint errorcatch+ standalone proof (manually simulated)requestDiscordwith customfetcherreturning malformed JSON, exercises the actual changed try/catch path