Skip to content

fix: validate --concurrency flag is at least 1 - #2400

Merged
TerryHowe merged 2 commits into
oras-project:mainfrom
aloneangel45:fix/validate-concurrency-flag
Nov 27, 2026
Merged

TerryHowe merged 2 commits into
oras-project:mainfrom
aloneangel45:fix/validate-concurrency-flag

Conversation

@aloneangel45

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

  • Adds a shared option.Concurrency (cmd/oras/internal/option/concurrency.go) implementing FlagApplier and FlagParser so --concurrency values below 1 fail consistently with "concurrency value should be at least 1" during option.Parse.
  • Adopts option.Concurrency across �ttach, �ackup, cp, pull, push,
    estore, ag, and manifest push while preserving each command's existing default concurrency (3 or 5).
  • Updates graph.FindPredecessors to check opts.Concurrency > 0 instead of != 0 so negative limits cannot leave the errgroup unbounded.
  • Adds unit tests for option.Concurrency, the 8 commands' default values and < 1 rejection, graph.FindPredecessors negative concurrency handling, and E2E validation/update of cp referrer tests.

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

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?

Comment thread internal/graph/graph.go Resolved

@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 Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.88%. Comparing base (edb7a23) to head (2f3b3f6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2400      +/-   ##
==========================================
+ Coverage   90.79%   90.88%   +0.08%     
==========================================
  Files         157      158       +1     
  Lines        7163     7172       +9     
==========================================
+ Hits         6504     6518      +14     
+ Misses        384      381       -3     
+ Partials      275      273       -2     

☔ 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 06d6343 into oras-project:main Nov 27, 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: --concurrency silently accepts negative and zero values

2 participants