Skip to content

chore(ux): improve oras backup error message#1833

Merged
Wwwsylvia merged 6 commits into
oras-project:mainfrom
Wwwsylvia:backup_err_msg
Aug 27, 2025
Merged

chore(ux): improve oras backup error message#1833
Wwwsylvia merged 6 commits into
oras-project:mainfrom
Wwwsylvia:backup_err_msg

Conversation

@Wwwsylvia

@Wwwsylvia Wwwsylvia commented Aug 27, 2025

Copy link
Copy Markdown
Member

What this PR does / why we need it:

This PR improves the error message in oras backup for the case where the output path ends with .tar but is an existing directory.

BEFORE:

Error: unable to create output file test.tar: open test.tar: is a directory

image

AFTER:

Error: the output path test.tar already exists and is a directory: open test.tar: is a directory
To back up to a tar archive, please specify a different output file name or remove the existing directory.

image

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

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?

Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>

This comment was marked as outdated.

@codecov

codecov Bot commented Aug 27, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.25%. Comparing base (97cb6f7) to head (29b3c8c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1833      +/-   ##
==========================================
+ Coverage   85.21%   85.25%   +0.04%     
==========================================
  Files         143      143              
  Lines        6737     6742       +5     
==========================================
+ Hits         5741     5748       +7     
+ Misses        708      707       -1     
+ Partials      288      287       -1     

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread cmd/oras/root/backup.go Outdated
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia requested a review from Copilot August 27, 2025 11:58

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 improves the error message when using oras backup with an output path that ends with .tar but points to an existing directory instead of a file. The enhancement provides clearer guidance to users about the conflict and suggests actionable solutions.

  • Enhanced error handling to detect directory conflicts when creating tar archives
  • Added user-friendly error message with specific recommendations
  • Included comprehensive test coverage for the new error scenario

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/oras/root/backup.go Added directory detection logic and improved error message for tar output conflicts
test/e2e/suite/command/backup.go Added end-to-end test to verify the new error message behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread cmd/oras/root/backup.go Outdated
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Comment thread cmd/oras/root/backup.go Outdated
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>

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

LGTM

@Wwwsylvia Wwwsylvia merged commit 02757a3 into oras-project:main Aug 27, 2025
8 checks passed
@Wwwsylvia Wwwsylvia deleted the backup_err_msg branch August 27, 2025 13:13
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.

Improve error message in oras backup when output .tar path is a directory

3 participants