Skip to content

fix: Fallback to blob upload when cross-repo mount fails - #1924

Merged
TerryHowe merged 7 commits into
oras-project:mainfrom
bupd:fall-orascp
Jun 12, 2026
Merged

TerryHowe merged 7 commits into
oras-project:mainfrom
bupd:fall-orascp

Conversation

@bupd

@bupd bupd commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

What this PR does / why we need it
ORAS currently fails to push when registry(Harbor) denies a cross-repository blob mount, which happens when the destination user lacks access to the source project. In private registries this is common, making mount attempts unreliable.

This PR makes ORAS automatically fall back to a normal blob upload when the mount is denied, matching expected registry client behavior and ensuring pushes succeed even without cross-project permissions.

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

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? No
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

@shizhMSFT shizhMSFT changed the title Fix: Fallback to blob upload when cross-repo mount fails fix: Fallback to blob upload when cross-repo mount fails Dec 9, 2025
@shizhMSFT
shizhMSFT requested a review from Copilot December 9, 2025 10:48

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.

Pull request overview

This PR adds automatic fallback to regular blob upload when cross-repository blob mount fails due to permission errors. ORAS currently fails when Harbor or other registries deny mount requests from private repositories the user doesn't have access to. This change makes the tool resilient by retrying the operation without the mount optimization when permission-related errors are detected.

Key Changes:

  • Refactored copy logic into a reusable executeCopy closure to enable retry functionality
  • Added error detection and retry logic that disables mounting when authorization failures occur
  • Maintained all existing copy paths (recursive, empty reference, and standard copy)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/oras/root/cp.go Resolved
Comment thread cmd/oras/root/cp.go Resolved
Comment thread cmd/oras/root/cp.go Resolved

@shizhMSFT shizhMSFT 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.

Other parts of the code looks fine.

Comment thread cmd/oras/root/cp.go Resolved
@codecov

codecov Bot commented Dec 17, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.21%. Comparing base (db75d4c) to head (28b650b).

Files with missing lines Patch % Lines
cmd/oras/root/cp.go 92.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1924      +/-   ##
==========================================
- Coverage   87.23%   87.21%   -0.02%     
==========================================
  Files         138      138              
  Lines        5467     5476       +9     
==========================================
+ Hits         4769     4776       +7     
- Misses        417      419       +2     
  Partials      281      281              

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

@bupd

bupd commented Dec 17, 2025

Copy link
Copy Markdown
Contributor Author

@shizhMSFT , @Wwwsylvia fixed review comments,

Thanks for the review.

@bupd
bupd requested a review from shizhMSFT December 19, 2025 23:39

@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

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions Bot added the stale Inactive issues or pull requests label Feb 14, 2026
@TerryHowe TerryHowe added this to the v1.4.0 milestone Feb 14, 2026
@TerryHowe TerryHowe added keep open and removed stale Inactive issues or pull requests labels Feb 14, 2026
@TerryHowe
TerryHowe requested a review from sabre1041 as a code owner June 12, 2026 11:47
@TerryHowe
TerryHowe merged commit e61c784 into oras-project:main Jun 12, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oras copy can not handle separate authentication for same registry

5 participants