butane/util: use yaml instead of json for unmarhal - #2310
butane/util: use yaml instead of json for unmarhal#2310angelcerveraroldan wants to merge 1 commit into
Conversation
Since yaml is a super-set of json, we can use the yaml unmarshal function instead of the json one. This unmarshalling will be more accurate, as it does not convert numbers to floats (which would lead to awkward formatting of the generated MCO) closes: coreos#2309
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (3)
|
| Layer / File(s) | Summary |
|---|---|
Intermediate configuration decoding butane/config/util/util.go |
TranslateBytesYAML uses yaml.Unmarshal instead of json.Unmarshal before YAML re-encoding. |
Estimated code review effort: 1 (Trivial) | ~3 minutes
Merge Risk: ⚪ Minimal · up to f7289
This localized change switches YAML unmarshalling to preserve numeric values more accurately; no actionable merge-blocking risk remains beyond normal checks and review.
Suggested reviewers: prestist
🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Linked Issues check | ✅ Passed | The change addresses issue #2309 by replacing JSON unmarshalling with YAML unmarshalling to preserve large integer MiB values and prevent scientific notation in generated MachineConfigs. |
| Out of Scope Changes check | ✅ Passed | The pull request changes one relevant unmarshalling call and contains no unrelated code changes. |
| Commit Message Convention | ✅ Passed | PASS. The PR contains one non-merge commit. Its subject is butane/util: use yaml instead of json for unmarhal: it has a subsystem, the description starts with lowercase use, uses imperative mood, … |
| Title check | ✅ Passed | The title describes the YAML-for-JSON unmarshalling change, uses the required subsystem prefix, uses lowercase wording after the colon, and uses imperative mood. The description contains a typo in “un… |
| Description check | ✅ Passed | The description directly explains the YAML unmarshalling change, its effect on numeric formatting, and the remaining test and release note work. |
Full details: Commit Message Convention
Explanation
PASS. The PR contains one non-merge commit. Its subject is butane/util: use yaml instead of json for unmarhal: it has a subsystem, the description starts with lowercase use, uses imperative mood, and has no trailing period. The commit is the only commit in the PR range.
Full details: Title check
Explanation
The title describes the YAML-for-JSON unmarshalling change, uses the required subsystem prefix, uses lowercase wording after the colon, and uses imperative mood. The description contains a typo in “unmarhal,” but remains clear.
- Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment @coderabbitai help to get the list of available commands.
148aff9 to
f728981
Compare
Binary size report (
|
| Size | |
|---|---|
Base (main) |
33MiB |
| PR (#2310) | 33MiB |
| Delta | -60KiB (-0.18%) |
|
Seems like the issue was coming from how we handle MCO. We first generate the igntion json from the butane yaml, then we unmarshal said json, and re-marshal it in yaml. In the step where we are unmarshal'ing the json igntion config, we lose the type information, and It seems that the reason we have to do this whole back and forth is due to missing functionality in the yaml library we use - which has been deprecated for about a year an a half now. I wonder if its worth looking into using an alternative yaml library that's maintained. @prestist wdyt |
Since yaml is a superset of json, we can use the yaml unmarshal function instead of the json one.
This unmarshalling will be more accurate, as it does not convert numbers to floats (which would lead to awkward formatting of the generated MCO)
Adding test and release note is still needed
closes: #2309