Skip to content

fix: keep --from-resolve and --to-resolve rules separate - #2282

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
wleeaf:fix-binary-target-resolve-aliasing
Oct 24, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
wleeaf:fix-binary-target-resolve-aliasing

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

BinaryTarget.Parse built the per-side DNS rules by appending --from-resolve and --to-resolve to the same --resolve slice. pflag's StringArray often leaves that slice with spare capacity (for example 3 values give len 3, cap 4), so both append calls wrote into the same backing array and --from-resolve ended up with the --to-resolve rule.

This PR builds each side's rules with slices.Concat, as proposed in the issue, so each side gets its own slice.

The new TestBinaryTarget_Parse_resolveFlag parses the flags through a real cobra/pflag flag set and runs BinaryTarget.Parse. It covers 3 base rules (spare capacity, which fails without the fix), 4 base rules (no spare capacity), no base rules, and only one side-specific rule.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2277

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

BinaryTarget.Parse appended the side-specific rules to the shared
--resolve slice. When that slice had spare capacity, both appends wrote
into the same backing array, so --from-resolve ended up with the
--to-resolve rule. Build each side's rules with slices.Concat instead.

Fixes #2277

Signed-off-by: Wleeaf <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 22:33

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.81%. Comparing base (a325603) to head (38948e7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2282   +/-   ##
=======================================
  Coverage   60.81%   60.81%           
=======================================
  Files         140      140           
  Lines        6091     6091           
=======================================
  Hits         3704     3704           
  Misses       2166     2166           
  Partials      221      221           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe
TerryHowe merged commit fdf2ba3 into oras-project:main Oct 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: --resolve rules can leak from --to-resolve into --from-resolve

3 participants