Repository navigation
fix(rust): omit absent params instead of writing "params": null - #2920
Merged
Merged
Conversation
`Request` (v1 and v2) and `Notification` carry `#[skip_serializing_none]`, but the attribute sat below `#[derive(Serialize)]`, where it has no effect. A request or notification without params was written as `"params": null`. JSON-RPC 2.0 lets `params` be omitted or structured, not `null`, so a strict peer can answer `-32600`. Move the attribute above the derives. Reading is unchanged: an omitted key and `null` both mean no params.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A request or notification without params was written as
"params": null.Request(v1 and v2) andNotificationcarry#[skip_serializing_none], but the attribute sat below#[derive(Serialize)], where it has no effect. Every other struct in the crate has it above the derives.JSON-RPC 2.0 lets
paramsbe omitted or be a structured value. It does not allownull, so a strict peer can answer-32600.Changes
v2::Request,v1::RequestandNotification. A message without params now omits the key.null.What changes for v1
Notificationis shared between the versions, and the v1 request had the same mistake. So v1 also stops writing"params": null. An omitted key is the valid JSON-RPC form, and both SDKs read it.Not changed
nullboth mean no params.Checks
cargo fmtpass.