go-sdk/internal
Repository files (latest commit first)
Filename Latest commit message Latest commit date
jansen b074c7f3af
internal/jsonrpc2: test WireError.Is and fix nil target panic (#1079)
# Problem
WireError.Is backs errors.Is checks used across the SDK against
sentinels such as ErrMethodNotFound, ErrRejected, and ErrClientClosing,
but had no direct test. Add a table-driven test for it.

While doing so, errors.Is(err, (*WireError)(nil)) was found to panic on
a nil pointer dereference, because Is read w.Code without a nil check.
Guard against a nil *WireError target so the comparison returns false.

  ```go
  errors.Is(err, (*WireError)(nil)) // panic: nil pointer dereference
 ```

# Approach


Is read w.Code after a successful type assertion without checking
whether w itself was nil. The fix guards against a nil *WireError target
so the comparison returns false instead of panicking.
# Test plan

  - go test ./internal/jsonrpc2/ passes.
- The new typed nil WireError case panics without the one-line fix and
passes with it, confirming the test exercises the guarded path.

Co-authored-by: Yaroslav <yarolegovich@gmail.com>
2026-08-21 10:56:31 +02:00
..
authutil mcp: add optional issuer validator for pre-registered client validation (SEP-2352) (#946) 2026-05-29 12:46:34 +00:00
docs docs: fix four dead links to the Multi Round-Trip Requests section (#1159) 2026-08-13 10:49:56 +02:00
json oauthex: use internal JSON library for decoding. (#866) 2026-03-30 14:52:15 +02:00
jsonrpc2 internal/jsonrpc2: test WireError.Is and fix nil target panic (#1079) 2026-08-21 10:56:31 +02:00
mcpgodebug mcp: update JSON marshaling to not HTML-escape messages (#769) 2026-01-30 17:13:30 +01:00
oauthtest auth: bind refreshing token source to a background context, not the request ctx (#988) 2026-06-16 16:42:53 +02:00
readme mcp: add documentation for new protocol version (#1019) 2026-06-23 17:07:38 +02:00
util internal: remove unused util functions (#871) 2026-03-31 15:40:06 +02:00
xcontext x/tools: modernize interface{} -> any 2025-02-19 15:14:27 -08:00