You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(core): qualify ResourceNotFoundError fromError reconstruction; fix cross-bundle example
- JSDoc / changeset / migration.md now state that ProtocolError.fromError
reconstructs ResourceNotFoundError for either code only when error.data
carries `uri`; a bare -32002 without data.uri stays a generic
ProtocolError.
- migration.md example: drop the outer `instanceof ProtocolError` gate
(it defeats the cross-bundle case the prose describes); the example now
feeds code+data straight into fromError and tests the locally-created
result.
Copy file name to clipboardExpand all lines: docs/migration.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1287,21 +1287,24 @@ with the `allowInputRequired: true` request option plus the `withInputRequired()
1287
1287
### Resource not found is `-32602` on every revision; typed `ResourceNotFoundError`
1288
1288
1289
1289
`resources/read` for an unknown URI now answers with JSON-RPC error code **`-32602` (Invalid Params)** on every protocol revision, with `error.data.uri` echoing the requested URI. The 2026-07-28 specification requires `-32602`; the v1.x SDK already emitted `-32602` on earlier
1290
-
revisions, so v1.x peers see no change. An interim `-32002` emission that shipped in earlier v2 alphas is reverted: the era encode seam maps any handler-thrown `-32002` to `-32602` on the wire, so a handler written against the older alpha behaves identically without changes.
1290
+
revisions, so v1.x peers see no change. An interim `-32002` emission that shipped in earlier v2 alphas is reverted: the era encode seam maps any handler-thrown `-32002` to `-32602` on the wire; note that a `-32002` thrown without `data.uri` is emitted as a bare `-32602` and is no longer recognizable as resource-not-found — throw `ResourceNotFoundError` (or include `data: { uri }`) to preserve the classification.
1291
1291
1292
1292
`ProtocolErrorCode.ResourceNotFound` (`-32002`) **remains importable** as receive-tolerated vocabulary: clients should accept both `-32602` and `-32002` from peers (the specification's backwards-compatibility clause). The new typed `ResourceNotFoundError` class carries the URI on
1293
-
`.uri`, and `ProtocolError.fromError`recognizes both codes by the `data.uri`shape — recognize peers' errors by their code and `error.data`, not by `instanceof`, which does not survive bundling. Servers must not return an empty `contents` array for a non-existent resource (an
1294
-
empty array is ambiguous between "exists but empty" and "does not exist").
1293
+
`.uri`, and `ProtocolError.fromError`reconstructs it from a `-32602` only when `error.data` is exactly `{ uri: string }` (and nothing else), and from a legacy `-32002` whenever `data.uri`is a string (a bare `-32002` without `data.uri` stays a generic `ProtocolError`) — recognize peers' errors by their code and `error.data`, not by `instanceof`, which does not survive
1294
+
bundling. Servers must not return an empty `contents` array for a non-existent resource (an empty array is ambiguous between "exists but empty" and "does not exist").
0 commit comments