Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a YAML→JSON→Go unmarshaling issue where numeric values can be coerced into float64, causing large integers (≥ 1e6) to render in scientific notation and break downstream bicep/bicepparam parsing. It introduces a custom JSON unmarshaler for types.Configuration to preserve integer types and adds unit tests to lock in the behavior.
Changes:
- Add
Configuration.UnmarshalJSONusingjson.Decoder.UseNumber()and recursively normalizejson.Numberintoint64orfloat64. - Add tests covering integers, floats, nesting, and arrays to ensure numeric type preservation and expected
fmt.Sprintrendering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| config/types/configuration.go | Adds custom JSON unmarshaling and recursive normalization to preserve integer numeric types. |
| config/types/configuration_test.go | Adds unit tests validating integer preservation and string rendering behavior across nested/array cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sigs.k8s.io/yaml converts all numbers to float64 when unmarshaling through the struct path (YAML → JSON → json.Unmarshal). For values >= 1e6, fmt.Sprint renders float64 in scientific notation (2e+06), which breaks bicep template parsing. Add UnmarshalJSON on types.Configuration using json.Decoder with UseNumber() to preserve integers as int64 and fractional values as float64. Ref: ARO-27909
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.
sigs.k8s.io/yaml converts all numbers to float64 when unmarshaling through the struct path (YAML → JSON → json.Unmarshal). For values >= 1e6, fmt.Sprint renders float64 in scientific notation (2e+06),
which breaks bicep template parsing, and required some hacky workarounds, e.g.
Add UnmarshalJSON on types.Configuration using json.Decoder with UseNumber() to preserve integers as int64 and fractional values as float64.
Why now: the conditional shown in the example does not translate well into EV2 artifacts, hence we want to make sure that things like these are disallowed in bicepparam files but first need to fix them properly
alse see: #255
https://redhat.atlassian.net/browse/ARO-27909