Skip to content

fix(rust): omit absent params instead of writing "params": null - #2920

Merged
benbrandt merged 1 commit into
mainfrom
fix/omit-absent-params
Nov 19, 2026
Merged

benbrandt merged 1 commit into
mainfrom
fix/omit-absent-params

Conversation

@benbrandt

Copy link
Copy Markdown
Member

Summary

A request or notification without params was written as "params": null.

Request (v1 and v2) and Notification carry #[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 params be omitted or be a structured value. It does not allow null, so a strict peer can answer -32600.

Changes

  • Move the attribute above the derives on v2::Request, v1::Request and Notification. A message without params now omits the key.
  • Three tests cover the output, and that reading still accepts both an omitted key and null.

What changes for v1

Notification is 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

  • Reading. An omitted key and null both mean no params.
  • The schema files.

Checks

  • Clippy, the tests, rustdoc and cargo fmt pass.
  • Regenerating the schema gives no diff.

`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.
@benbrandt
benbrandt requested a review from a team as a code owner November 19, 2026 22:17
@benbrandt
benbrandt merged commit bc1b89d into main Nov 19, 2026
13 checks passed
@benbrandt
benbrandt deleted the fix/omit-absent-params branch November 19, 2026 22:23
@acp-release-bot acp-release-bot Bot mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant