go-sdk/internal/jsonrpc2
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
..
conn.go internal/jsonrpc2: plumb cancellation cause through request context (#1103) 2026-08-21 10:16:28 +02:00
jsonrpc2.go internal/jsonrpc2: remove unused code (#910) 2026-04-28 09:56:15 +02:00
messages.go fix(jsonrpc2): decode requests when method key is present (#1000) 2026-06-16 09:57:18 +02:00
wire.go internal/jsonrpc2: test WireError.Is and fix nil target panic (#1079) 2026-08-21 10:56:31 +02:00
wire_test.go internal/jsonrpc2: test WireError.Is and fix nil target panic (#1079) 2026-08-21 10:56:31 +02:00