fix: preserve empty-method requests during decode
## Summary
Fixes #976.
DecodeMessage used msg.Method != "" to distinguish requests from responses. That means a wire payload with a present but empty method field, such as:
{"jsonrpc":"2.0","id":5,"method":"","params":{}}
was decoded as a response instead of a request. Since there was no matching outgoing call, the server ignored it and did not send a correlated JSON-RPC error, even though the session stayed alive.
This PR checks whether the wire payload contains the method field instead of checking whether the decoded string is non-empty. An empty method now reaches the normal request dispatch path and receives the existing method-not-found handling.
Tests
go test ./internal/jsonrpc2
go test ./mcp
go test ./...
git diff --check
Rebased on current origin/main and reran validation locally.
Validated:
gofmt -w $(git diff --name-only origin/main...HEAD | Where-Object { $_ -like '*.go' })
go test ./mcp
go test -race ./mcp
go test ./...
git diff --check origin/main...HEAD
All passed after the rebase.
Rebased this branch onto the latest upstream main and force-pushed the cleaned head.
Validated locally:
gofmt -l internal/jsonrpc2/messages.go internal/jsonrpc2/wire_test.go(no output)go test ./internal/jsonrpc2go test ./...git diff --check origin/main..HEAD
Rebased this branch onto current upstream main and reran the focused/full Go validation.
Validation:
gofmt -l internal\jsonrpc2\messages.go internal\jsonrpc2\wire_test.go
go test ./internal/jsonrpc2
go test ./...
git diff --check origin/main..HEAD
Current head: dbbe137.
Closing as duplicate of PR #1000