Repository navigation
plan(sdk): harden malformed-success decode errors - #1698
Conversation
b838fe8 to
b6e0582
Compare
Define the cause-free successful-response decoder boundary while preserving body-read, server, authentication, transport, and cancellation causes. Relates to #1694 Co-authored-by: Codex <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
b6e0582 to
c69d606
Compare
kantord
left a comment
There was a problem hiding this comment.
Review summary
Solid Architectural plan/interface PR — no blockers. Cross-checked the plan's claims against the actual TS SDK source and against the stacked implementation PR (#1700), and both hold up.
Verification performed
- Ran the acceptance-plan checker (
check-acceptance-plan.sh) againstdocs/acceptance/sdk-malformed-success-decoding.md: passes, with only the expected "no named Go test" warning (this plan is verified by vitest, not Go tests). - Ran
task docs:check(matlatl strict link/anchor check): 0 broken links, 0 broken anchors, 0 orphans, 0 unreachable across 436 docs. - Grepped
sdk/typescript/src/http.tsfor the four decode sites the ADR describes (invalid JSON×2,invalid response,invalid event) — they exist exactly as claimed, currently attaching the raw decoder exception ascause. The plan's premise is grounded in real code, not speculative. - Read the stacked implementation (#1700): it splits
response.json()intoresponse.text()(kept as a causedProtocolErroron read failure) followed by a separateJSON.parse()(cause-free on parse failure) — exactly the boundary ADR 0349 / Decision 4 requires between body-read failures and decoder rejections. SSE'sJSON.parse(next.value.data)was already naturally separated from the stream-read step, so no equivalent split was needed there. The interface contract was implementable as written, and was implemented as written.
One factual error to fix
The PR body's "Decision record" line points at docs/adr/0348-typescript-sdk-malformed-success-decoding.md. That's wrong — the actual new file in this diff is docs/adr/0349-typescript-sdk-malformed-success-decoding.md. 0348 is a different, already-merged ADR (TypeScript SDK MCP authorization lifecycle, #1687). Looks like a stale copy/paste from before the ADR number was finalized. Worth fixing so a reviewer clicking the link doesn't land on the wrong document — the acceptance plan and ADR file itself correctly use 0349 throughout.
Non-blocking nit
The new docs/adr/README.md entry for 0349 is inserted out of numeric order (after 0348, before 0342). That section was already out of strict numeric order before this PR (0347/0348 were previously inserted the same way), so this isn't a new regression — just continuing existing disorder in that list. Not worth blocking on.
Process
- Architectural classification is justified — this changes the durable security/diagnostic contract for
ProtocolErrorat the SDK's HTTP boundary. - Correctly uses the acceptance-plan spine with a new ADR for the durable decision.
- The documented "human waiver of spine" (allowing the implementation PR to stack without waiting for this plan PR to merge) matches
docs/development-process.md's carve-out: it lifts only plan/interface merge-order ceremony, not verification or human merge authority — both PRs still explicitly require human merge.
Fully or partially written by an AI agent.
Merge origin/main at 686b5e5. Incoming commits after the approved cleanup base: - 79fae4d chore(catalog): refresh models.dev curated subset (#1721) - 73309df chore(deps): bump anthropic-sdk-go (#1713) - e14c88d slack-bot: DM manual permission approvals (#1707) - 5b0db5a feat(sdk): add MCP authorization lifecycle (#1692) - 39715ed chore(deps): bump SDK npm dependencies (#1715) - 498971e plan(sdk): harden malformed-success decode errors (#1698) - 9ac4798 slack-bot: relabel session approval (#1724) - 8de41cd docs(process): route approved cleanup directly (#1720) - a711451 release v0.0.39 (#1727) - 44786d1 fix(sdk): sanitize malformed-success decode errors (#1700) - 85f97fa release TypeScript SDK v0.3.0 (#1729) - 6501b59 fix(ci): repair live compaction slot and metadata (#1728) - 8047188 chore(deps): bump toolhive-core (#1712) - 686b5e5 docs: add README diagrams (#1731) Conflict resolutions preserve the MCP authorization lifecycle from main while applying the approved alpha cleanup: Run and MCP continuation results consume canonical payload usage only; removed EventCommon usage and deprecated aliases stay removed. Keep the landed authorization acceptance record and both the Unreleased cleanup note and released v0.3.0 changelog. Regenerate API reports and user reference from the merged canonical TypeScript sources. Co-Authored-By: mecatl <[email protected]>
Summary
ProtocolError.cause.Development stage
Contract linkage
docs/adr/0348-typescript-sdk-malformed-success-decoding.mdgh stacklayer without waiting for this PR to merge; neither PR is authorized to merge heredocs/acceptance/sdk-malformed-success-decoding.mdInterface conformance
causeproperty.Issue relationship
Relates to #1694
Type of change
Test plan
Baseline checks
task lint)task test)go run ./cmd/mecademo)CGO_ENABLED=0 task docs)task site:build)task api:check)task api:update+engine/CHANGELOG.mdtask ac-trace-strict)/panel-reviewtask docsrequiresCGO_ENABLED=0in this worktree because the host Xcode/macOS SDK linker rejects its ownarm64e.x1-*architecture set; all documentation generation and strict link checks pass with CGO disabled.Changes
docs/acceptance/sdk-malformed-success-decoding.mddocs/adr/0348-typescript-sdk-malformed-success-decoding.mddocs/acceptance/README.md,docs/adr/README.mdUser-facing change
None in this PR; it defines the contract for the stacked implementation.
Special notes for reviewers
The decoder boundary begins only after a unary body has been acquired.
Response.json()combines body acquisition with JSON parsing, so the implementation must splitresponse.text()fromJSON.parse()to avoid stripping causes from body-read/network failures.