Repository navigation
Conversation
`str::parse::<f64>` returns `Ok(inf)` for an out-of-range literal such as `1e400`, so the parser accepted it and the compiler wrote `inf` into the artifact (`"value": inf`, which is not valid JavaScript) and into the operation text (`f(x: inf)`, which is not a Float value). GraphQL Float values are finite, and an integer literal that does not fit in an i64 is already reported as `InvalidInteger`. Report `InvalidFloat` for a Float literal that does not parse to a finite value.
This branch has not been deployed
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.
Fixes #5448
source.parse::<f64>()returnsOk(inf)for an out-of-range Float literal such as1e400. The parser accepted it, and the compiler wroteinfinto the artifact:"value": inf, so importing the artifact throwsReferenceError: inf is not defined, andf(x: inf)in the operation text. GraphQL Float values are finite (section 3.5.2), and an integer literal that does not fit in an i64 is already reported asInvalidInteger.With this change the parser reports the existing
InvalidFloaterror ("Invalid floating point value") when a Float literal does not parse to a finite value. This is stricter than graphql-js, whoseparseandvalidateboth accept1e400.Testing:
parse_executable_document/fixtures/float_out_of_range.invalid.graphql: the largest finite double still parses, and1e400gives the error. On main @ feb3b52,float_out_of_range_invalidfails ("Expected transform to error but it succeeded"); with this change it passes.cargo test -p graphql-syntax: all 96 tests pass.cargo test -p graphql-ir -p graphql-text-printer -p schema: all pass.relaybinary built with this change fails on the repro from the issue (1e400and-1e400) with✖︎ Invalid floating point valueand writes no artifact.1.7976931348623157e308still compiles to the same artifact as on main.rustfmt --checkwith the pinned nightly-2026-08-15 is clean forparser.rs. The fixture test file comes from thefixture_tests!macro, and runningfixture_tests_binleft it unchanged.graphql-syntaxtests on the final commit (the new fixture fails without theparser.rschange and passes with it). The downstream crates and therelaybinary were tested on the same code before I committed it.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.