Repository navigation
Fix panic on unsigned integer values in diff renderer and differ - #7560
AyushSrivastava1818 wants to merge 1 commit into
Conversation
Signed-off-by: AyushSrivastava1818 <ayush.sri0705@gmail.com>
✅ Deploy Preview for pipecd-site canceled.
|
|
👋 Hi @AyushSrivastava1818, welcome to PipeCD and thanks for opening your first pull request! We’re really happy to have you here Before your PR gets merged, please check a few important things below. Helpful resources
DCO Sign-offAll commits must include a In case you forget to sign-off your commit(s), follow these steps: For the last commit: git commit --amend --signoff
git push --force-with-leaseFor multiple commits: git rebase --signoff origin/master
git push --force-with-leaseRun checks locallyBefore pushing updates, please run: make checkThis runs the same checks as CI and helps catch issues early. 💬 Need help?If anything is unclear, feel free to ask in this PR or join us on the CNCF Slack in the #pipecd channel. Thanks for contributing to PipeCD! ❤️ |
There was a problem hiding this comment.
🟡 Changes recommended
Converting unsigned integers to float64 loses precision above 2^53, causing distinct manifest values to compare equal and suppressing valid diffs; exact integer comparison and a large-uint64 regression test are needed.
1 open issue
What changed in this PR
This PR addresses #7559 by fixing unsigned-integer panics in PipeCD’s diff renderer and extending unsigned-number support in the differ.
Changes:
- Format unsigned values using
Uint()andFormatUint. - Recognize unsigned numeric kinds and safely handle two invalid reflection values.
- Add tests for unsigned formatting, comparisons, numeric-string coercion, and invalid operands.
| File | Description |
|---|---|
pkg/diff/renderer.go |
Separates signed and unsigned integer formatting. |
pkg/diff/renderer_test.go |
Adds unsigned primitive-formatting tests. |
pkg/diff/diff.go |
Adds unsigned numeric support and an invalid-value guard. |
pkg/diff/diff_test.go |
Tests unsigned comparisons, numeric strings, and invalid operands. |
Review effort: Balanced
| case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: | ||
| return float64(v.Uint()) |

What this PR does:
pkg/diff/renderer.gowhererenderNodeValueandRenderPrimitiveValueinvokedv.Int()onreflect.Uint...types instead ofv.Uint().pkg/diff/diff.go(isNumberValue,convertToNumber,floatNumber) to support all unsigned integer kinds (Uint,Uint8,Uint16,Uint32,Uint64).diff()when comparing two invalidreflect.Valueoperands (!vx.IsValid() && !vy.IsValid()) to avoid panics onvy.Type().diff_test.goandrenderer_test.gocoveringuintformatting, comparison, numeric string coercion, and invalid operands.Why we need it:
Calling
v.Int()on any unsigned integer in Go panics withreflect: call of reflect.Value.Int on uint64 Value. When manifests containing unsigned integer fields (such as ports, uid/gid, replica counts) are rendered by piped's drift detector or diffing tools, this panic crashed the process. Additionally,diff.gopreviously rejected comparisons of uint values with<kind> kind is not handled.Which issue(s) this PR fixes:
Fixes #7559
Does this PR introduce a user-facing change?:
Screenshots/Videos (for documentation or website changes):
N/A