JerseyYee opened a new pull request, #6917:
URL: https://github.com/apache/rocketmq-dashboard/pull/6917

   ## Which Issue(s) This PR Fixes
   
   Fixes #6904
   
   ## Brief Description
   
   The SDK's `RequestId.UnmarshalJSON` and `NotificationParams.UnmarshalJSON` 
decode every JSON number through `float64`, so the rmqctl bridge corrupted 
valid JSON-RPC identities before forwarding them: a request sent as 
`9007199254740993` reached the wire as `9007199254740992`, an adjacent response 
(`...992`) was incorrectly accepted for a `...993` request, and cancellation 
notifications rounded their `params.requestId`. Because two adjacent large ids 
decode to the *same* float64, concurrent requests could be correlated with each 
other's responses.
   
   ### Changes (1 file, +63)
   
   - `decodeMCPMessage` now re-decodes the raw `id` field losslessly 
(`losslessRequestID`): integer literals that fit in int64 keep their exact 
value via `mcp.NewRequestId(int64)`, which the SDK marshals back verbatim; 
every other shape (strings, decimals, out-of-range numbers) keeps the SDK's 
decoded value so behavior stays symmetric with what the transport and peer 
decode.
   - The same restore is applied to `notifications/cancelled`'s 
`params.requestId`; frames whose params fail to decode keep the SDK's decoded 
value, and frames without a `requestId` are never injected with one.
   - Response correlation still rejects any response whose decoded id differs 
from the forwarded id, so numeric-vs-string distinctions are retained.
   
   ### Scope note
   
   The response-side decode happens inside the SDK 
(`json.NewDecoder(...).Decode(&response)` in 
`client/transport/streamable_http.go`), which this PR deliberately does not 
fork. With the sender fixed, an adjacent or mismatched response is now 
**rejected** instead of silently accepted, and cancellation forwarding is 
lossless. A peer echo of a large numeric id still decodes rounded on the 
response side; completing that scenario needs the upstream fix 
(mark3labs/mcp-go#1032) in a released SDK version, per the follow-up plan in 
#6904.
   
   ## How Did You Test This Change?
   
   ```
   go test ./internal/studio/ -run 
'RequestID|AdjacentResponse|MatchingLarge|TypeDistinctions|WithoutRequestID|InvalidIDShape|LargeIntegerIDs|SmallAndString'
 -v
   ```
   
   - With the fix: 9 tests covering all 4 defect scenarios and all 6 controls 
from the issue table pass.
   - Fix stashed while keeping the new tests: 
`TestDecodeRequestPreservesLargeIntegerIDs`, 
`TestSendRequestRejectsAdjacentResponseID`, 
`TestSendRequestAcceptsMatchingLargeResponseID` and 
`TestDecodeCancellationPreservesLargeRequestID` fail with exactly the rounding 
symptoms described in #6904 (red/green verified).
   - `go test ./...`, `go vet ./...` clean; `gofmt` reports no diff for the 
touched files.
   
   ## Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled (1 file, 
+63)
   - [x] Commit subject follows Conventional Commits and is `[studio]`-prefixed
   - [x] Tests added/updated for non-trivial changes
   - [x] New source files carry the ASF license header (tests: 
`mcp_request_id_test.go`)
   - [x] No UI text / i18n changes
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to