Skip to content

f32 fields parse numbers above f32::MAX as infinity, then serialize as null #1553

In review

Description

@ragen1337

json_float::option_f32 (crates/rmcp/src/model/serde_impl.rs) casts the parsed f64 with as f32, so values above f32::MAX turn into inf. The roundtrip check in the jsonrpc_message fuzz target for #1533 fails on it.

Repro (parsed as ServerJsonRpcMessage):

{"jsonrpc":"2.0","id":1,"method":"sampling/createMessage","params":{"messages":[],"maxTokens":1,"temperature":1e39}}

params.temperature parses as Some(inf), serde_json::to_string writes "temperature":null, and parsing that back gives None. Same for Annotations.priority and the ModelPreferences priority fields.

1e400 is already rejected (fields_reject_anything_but_a_finite_number), so 1e39 in an f32 field should fail the same way ("number out of range"). Plain serde f32 does the same as cast, so this isn't new in #1300; it just doesn't match what the module comment says.

I'll open a PR with a fix and a test.

Activity

  1. added
    bug
    P2
    T-model
    ready for work
    on Dec 3, 2026
  2. github-actions commented on Dec 3, 2026

    @github-actions
    Contributor

    @connor4312 is on triage rotation this week and is the reviewer for this one.

    Codex labeled this bug / P2 (T-model). Please confirm or correct those labels.

    Automated triage. Labels are a first pass and the assigned maintainer has the final say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2T-modelbugready for work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions