Skip to content

fix(model): reject a number beyond f32 in f32 fields - #1554

Open
ragen1337 wants to merge 1 commit into
modelcontextprotocol:mainfrom
ragen1337:fix/f32-out-of-range
Open

ragen1337 wants to merge 1 commit into
modelcontextprotocol:mainfrom
ragen1337:fix/f32-out-of-range

Conversation

@ragen1337

Copy link
Copy Markdown
Contributor

Fixes #1553.

json_float::option_f32 was casting the parsed f64 with as f32, so values like 1e39 became infinity and serialized back as null. Values that don't fit in f32 now fail with "number out of range", the same way 1e400 does.

Added a test covering Annotations.priority, CreateMessageRequestParams.temperature, and the three ModelPreferences priorities with 1e39 and -1e39 (fails before this change). json_float tests, test_deserialization, fmt, and clippy all pass.

json_float::option_f32 narrowed the parsed f64 with `as f32`, so a value
such as 1e39 became infinity. serde_json writes infinity as null, so the
field was lost when the message was sent on. Reject it as out of range,
like a number beyond f64.
@ragen1337
ragen1337 requested a review from a team as a code owner December 3, 2026 09:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T09:04:34.103235Z 8e70944 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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.

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

1 participant