Repository navigation
model: decode JSON escapes in quoted float values - #1048
Open
AmanBoronbaev wants to merge 1 commit into
Open
AmanBoronbaev wants to merge 1 commit into
AmanBoronbaev wants to merge 1 commit into
Conversation
Signed-off-by: Aman <149809343+AmanBoronbaev@users.noreply.github.com>
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.
SampleValueandFloatStringstrip the surrounding JSON quotes but pass escape sequences directly tostrconv.ParseFloat. As a result, the valid JSON string"\u0031"fails to decode, while the equivalent"1"succeeds.Unescape strings containing backslashes with
encoding/jsonbefore parsing the float. Share this logic between sample and histogram values, preserving the existing direct parsing path for unescaped strings and the rejection of unquoted values.Add regression coverage for zero, negative zero, the largest float64, the smallest subnormal, NaN, both infinities, overflow and invalid input. The same cases run through
encoding/jsonand, on Go 1.27,encoding/json/v2. Add a benchmark for plain and escaped sample values; the plain path remains at 0 B/op and 0 allocs/op in local measurements.Validation:
go test ./...passes on Go 1.27.4. Proxy environment variables were cleared for the test process so the HTTP proxy tests could control their own environment.go test -race ./modelpasses; model tests also pass on Go 1.26.11.go vet ./..., the repository's golangci-lint v2.14.0 configuration, formatting and license checks pass.@gotjosh, requesting review as directed by CONTRIBUTING.md.