Handle malformed GitHub PR merge failure bodies
A rejected GitHub PR merge can return HTML, plain text, empty content or unusable JSON. The existing helper parses every failed response as JSON, so these responses can crash failure handling instead of producing a clear error.
This guards only failed-response parsing/message selection. A nonblank GitHub string message is preserved exactly; other successfully read bodies return GitHub merge failed (HTTP <status>). Network and body-read exceptions still propagate. The endpoint, token forwarding, PUT/squash request, single-request behavior and success path are unchanged. No retry, reconciliation, permission or merge-policy change is included.
The real action handler's mocked HTML-failure case confirms it reports failure without changing PR state or calling the success handler. This is the previously accepted three-file repair, composed unchanged on actual post-1117 main 0529215aa7692d6162950ae837b34a64c8e69840; relevant coding-agent source and dependency manifests have no drift from its original base.
Validation at 0aae7bb87e1790fc70e4b8d82c014f317877e1cc:
- Actual current-base regression: 10 failures / 3 passing controls; corrected: 13 passing tests.
- Broader coding-agent suite: 114 passing tests across 26 files, including those 13.
- Focused production-helper TypeScript, repository lint, changed-file formatting and diff checks pass.
- Prior static independent Standards0/Spec0 is rebound by exact accepted blobs/patch; fresh independent execution is Records-owned and remains required before coordinator merge.
- All responses/tokens are synthetic and HTTP is mocked. No real GitHub merge, comment delivery, credential read, database/provider operation or manual deployment was performed. No whole-project typing or live behavior claim.
Refs recoupable/mono#358, recoupable/mono#318. Coordinator alone merges after exact-head checks and acceptance.
Summary by cubic
Fixes GitHub merge failure handling so a rejected PR merge returning HTML, plain text, an empty body, or malformed JSON reports a clear error instead of crashing failure reporting, since failed responses were previously parsed as JSON unconditionally. This addresses the reproduced Mono #358/#318 finding about unguarded JSON parsing.
Bug Fixes
mergeGithubPRpreserves exact nonblank GitHubmessagestrings; other readable bodies fall back toGitHub merge failed (HTTP <status>).- Network and body-read exceptions still propagate, and the success path, endpoint, token forwarding, and PUT/squash request are unchanged.
- Adds 13 regression tests and a verification doc covering malformed bodies, exact message preservation, and unchanged error propagation.