Skip to content

fix: clean up partial pull output on failure - #2194

Merged
TerryHowe merged 5 commits into
oras-project:mainfrom
TanvirTian:fix/pull-partial-output
Sep 28, 2026
Merged

TerryHowe merged 5 commits into
oras-project:mainfrom
TanvirTian:fix/pull-partial-output

Conversation

@TanvirTian

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
When oras pull downloads multiple platform manifests that contain files with the same name, the pull can fail with duplicate name after one of the files has already been written to the output directory.

This change tracks files created during the pull and removes them when the pull fails, preventing partial output from being left behind.

Existing files are not removed during cleanup, preserving the normal overwrite behavior of oras pull.

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 #2193

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?

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.36364% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.83%. Comparing base (87495d5) to head (a83b652).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/root/pull.go 86.36% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2194      +/-   ##
==========================================
+ Coverage   87.81%   87.83%   +0.02%     
==========================================
  Files         139      139              
  Lines        5689     5756      +67     
==========================================
+ Hits         4996     5056      +60     
- Misses        413      417       +4     
- Partials      280      283       +3     

☔ 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 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.

Suggestions below are applied and verified on top of eca21fb — go build ./..., gofmt, and go test -race ./cmd/oras/... all clean.

The one behavioural point not covered by a suggestion: cleanup currently fires on any doPull error, so Ctrl-C or a dropped connection mid-pull discards everything downloaded so far. Worth deciding whether to gate it on the duplicate-name case rather than every error path.

Comment thread cmd/oras/root/pull.go Resolved
Comment thread cmd/oras/root/pull.go Resolved
Comment thread cmd/oras/root/pull.go Resolved
Comment thread cmd/oras/root/pull.go Resolved
Comment thread cmd/oras/root/pull_test.go Resolved
Comment thread cmd/oras/root/pull_test.go Resolved
@TanvirTian

TanvirTian commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor Author

I tried the errdef.ErrDuplicateName suggestion as it is, but it isn't available in the oras-go/v2.6.2 version currently used by this branch. I kept the equivalent file.ErrDuplicateName check instead, and the test passes with the current dependency version.

Comment thread cmd/oras/root/pull.go Resolved
Comment thread cmd/oras/root/pull.go Resolved
@TanvirTian

Copy link
Copy Markdown
Contributor Author

Thanks @TerryHowe, Fixed both of these

@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

@TerryHowe
TerryHowe merged commit 7c53cbf into oras-project:main Sep 28, 2026
10 checks passed
@TerryHowe

Copy link
Copy Markdown
Member

Thanks!

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.

oras pull: leaves partial output after duplicate-name failure on multi-platform artifacts

2 participants