Skip to content

Fix panic on unsigned integer values in diff renderer and differ - #7560

Open
AyushSrivastava1818 wants to merge 1 commit into
pipe-cd:masterfrom
AyushSrivastava1818:fix-diff-uint-panic
Open

AyushSrivastava1818 wants to merge 1 commit into
pipe-cd:masterfrom
AyushSrivastava1818:fix-diff-uint-panic

Conversation

@AyushSrivastava1818

Copy link
Copy Markdown

What this PR does:

  • Fixes a runtime panic in pkg/diff/renderer.go where renderNodeValue and RenderPrimitiveValue invoked v.Int() on reflect.Uint... types instead of v.Uint().
  • Extends pkg/diff/diff.go (isNumberValue, convertToNumber, floatNumber) to support all unsigned integer kinds (Uint, Uint8, Uint16, Uint32, Uint64).
  • Guards diff() when comparing two invalid reflect.Value operands (!vx.IsValid() && !vy.IsValid()) to avoid panics on vy.Type().
  • Adds comprehensive unit tests in diff_test.go and renderer_test.go covering uint formatting, comparison, numeric string coercion, and invalid operands.

Why we need it:
Calling v.Int() on any unsigned integer in Go panics with reflect: 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.go previously 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?:

  • How are users affected by this change: Piped and control plane will no longer panic when computing or rendering diffs on manifests containing unsigned integer values.
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Screenshots/Videos (for documentation or website changes):
N/A

Signed-off-by: AyushSrivastava1818 <ayush.sri0705@gmail.com>
@AyushSrivastava1818
AyushSrivastava1818 requested a review from a team as a code owner October 30, 2026 20:15
@AyushSrivastava1818
AyushSrivastava1818 requested review from Warashi, ffjlabo and t-kikuc and a balanced review from Copilot October 30, 2026 20:15
@netlify

netlify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for pipecd-site canceled.

Name Link
🔨 Latest commit c211c06
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6ae4fad2c6c24521ef9ae5b5

@github-actions

Copy link
Copy Markdown
Contributor

👋 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-off

All commits must include a Signed-off-by line to comply with the Developer Certificate of Origin (DCO).

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-lease

For multiple commits:

git rebase --signoff origin/master
git push --force-with-lease

Run checks locally

Before pushing updates, please run:

make check

This 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.
You can get your Slack invite from: https://communityinviter.com/apps/cloud-native/cncf

Thanks for contributing to PipeCD! ❤️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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() and FormatUint.
  • 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

Comment thread pkg/diff/diff.go
Comment on lines +410 to +411
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return float64(v.Uint())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix panic on unsigned integer values in diff renderer and differ

2 participants