Skip to content

fix(sdk): sanitize malformed-success decode errors - #1700

Merged
samuv merged 1 commit into
mainfrom
impl/sdk-malformed-success-causes
Sep 21, 2026
Merged

samuv merged 1 commit into
mainfrom
impl/sdk-malformed-success-causes

Conversation

@samuv

@samuv samuv commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Remove runtime JSON/protobuf decoder exceptions from malformed successful unary HTTP and ordinary SSE ProtocolError values.
  • Retain safe HTTP status and request-ID metadata while preserving existing body-read, server, authentication, fetch/network, abort, cancellation, and SSE-reader causes.
  • Add red-green regression coverage for JSON, well-known-type normalization, and actual protobuf-es failures on both unary and streaming paths.

Development stage

  • Plan / Interface — Bounded/Architectural behavioral and exact-interface contract; no implementation
  • Implementation — based on the exact Plan / Interface commit below under the directing human's explicit pre-merge stacking waiver
  • Combined — compact one-task Bounded/Architectural exception; no separate plan PR
  • Spike / Routine — acceptance-plan spine exempt

Contract linkage

  • Work classification: Architectural
  • Classification rationale: changes the durable public diagnostic and security policy at the TypeScript SDK HTTP successful-response boundary
  • Decision record: docs/adr/0348-typescript-sdk-malformed-success-decoding.md
  • Human waiver of spine: Yes — the directing user explicitly authorized this Implementation PR as the next gh stack layer without waiting for the Plan / Interface PR to merge; neither PR is authorized to merge here
  • Acceptance plan: docs/acceptance/sdk-malformed-success-decoding.md
  • Human decisions resolved and recorded: Yes
  • Plan / Interface PR: plan(sdk): harden malformed-success decode errors #1698
  • Approved commit baseline: b6e05820685a85bf3cf027ed42da4e269060e6ed under the recorded stacking waiver; it is not yet merged authority
  • Combined/exemption rationale: N/A — delivery remains Split

Interface conformance

Matches the exact committed plan contract. There are no protobuf, Go API, tool, CLI/config, event, persistence, or public TypeScript signature changes.

Issue relationship

Closes #1694

Type of change

  • Behavioral/interface plan
  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation/process
  • Other (describe):

Test plan

Baseline checks

  • Acceptance-plan checker
  • Linting (task lint)
  • Offline test suite (task test) — host Xcode/macOS 27 linker rejects its own arm64e.x1-* SDK architectures across CGO-linked test binaries; one unrelated TestCarryoverHandoff also timed out during the degraded run. CI must supply this proof.
  • Offline demo (CGO_ENABLED=0 go run ./cmd/mecademo)
  • Markdown changed: docs generation/link checks (CGO_ENABLED=0 task docs)
  • User docs/user-facing behavior changed: site build (task site:build)
  • Guarded engine API affected: N/A — no engine API change
  • Intentional engine API change: N/A
  • Landed plan: strict acceptance trace — plan remains an in-progress stacked candidate until the full CI gate passes
  • Final implementation review: /panel-review

Additional SDK gates:

  • task sdk:lint sdk:typecheck sdk:test sdk:build sdk:api:check sdk:docs:check
  • 56 Vitest files and 306 tests pass with the complete decoder-stage cases; the focused suite passes all 3 tests.
  • Panel result after the reviewer-requested true protobuf-es fixtures: Spec 0, Standards 0, Test adequacy 0, Domain 0.

Changes

File Change
sdk/typescript/src/http.ts Single cause-free malformed-success constructor and split body acquisition/JSON parsing
sdk/typescript/test/http-decoding-errors.test.ts Unary/SSE decode and neighboring-error regression matrix
sdk/typescript/src/errors.ts, generated API reference Public diagnostic contract
TypeScript SDK guide and living architecture/design notes Safe logging and boundary documentation
Acceptance plan/index Stacked candidate status and exact waived baseline

User-facing change

Applications receive the same ProtocolError class, code, message, transport, and status for malformed successful HTTP/SSE payloads, plus a response request ID when present. These errors no longer expose the decoder exception through cause.

Special notes for reviewers

Unary body acquisition is intentionally separate from JSON.parse(): a response.text() failure retains the existing caused ProtocolError. SSE reader.read() failures remain outside decoder catches. The final CI test result is the only pending acceptance-plan gate; this PR does not claim the plan is landed.

Omit decoder causes at the successful HTTP and SSE payload boundary while retaining safe metadata and 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]>
@samuv
samuv force-pushed the impl/sdk-malformed-success-causes branch from a343b22 to 1ccbc39 Compare September 21, 2026 14:54
@samuv
samuv merged commit 44786d1 into main Sep 21, 2026
36 checks passed
@samuv
samuv deleted the impl/sdk-malformed-success-causes branch September 21, 2026 15:08
JAORMX added a commit that referenced this pull request Sep 21, 2026
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]>
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 22, 2026
2 tasks

This branch was successfully deployed

1 active deployment
Preview — 1ccbc395 Deployed Sep 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK: sanitize malformed-success HTTP decoding causes

1 participant