Skip to content

Conversation

Wwwsylvia
Copy link
Member

@Wwwsylvia Wwwsylvia commented Mar 31, 2025

  1. Introduce a new error type CopyError and return it from Copy and ExtendedCopy when necessary
  2. Add corresponding unit tests
  3. Add a example for the CopyError type

Resolve #677

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>
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>
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>
Copy link

codecov bot commented Mar 31, 2025

Codecov Report

Attention: Patch coverage is 85.50725% with 10 lines in your changes missing coverage. Please review.

Project coverage is 81.69%. Comparing base (6dd6913) to head (22c52e6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
copy.go 74.19% 7 Missing and 1 partial ⚠️
copyerror.go 92.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #933      +/-   ##
==========================================
+ Coverage   81.25%   81.69%   +0.44%     
==========================================
  Files          63       64       +1     
  Lines        6076     6119      +43     
==========================================
+ Hits         4937     4999      +62     
+ Misses        801      790      -11     
+ Partials      338      330       -8     

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

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>
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>
@Wwwsylvia Wwwsylvia requested a review from Copilot April 1, 2025 06:27
Copy link

@Copilot Copilot AI left a comment

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 introduces a new error type, CopyError, to better indicate error origins in copy operations by wrapping errors with additional context. Key changes include:

  • Replacing plain error messages with structured CopyError instances across copy and extended copy functions.
  • Updating test cases to assert error types and origins using errors.Is and type assertions.
  • Adding dedicated tests and examples for CopyError behavior.

Reviewed Changes

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

Show a summary per file
File Description
internal/platform/platform_test.go Updated error assertions to use errors.Is
internal/platform/platform.go Wrapped error with errdef.ErrUnsupported using error wrapping
extendedcopy_test.go Modified tests to check for CopyError and correct origins
extendedcopy.go Updated error handling in ExtendedCopy functions
example_copyerror_test.go Added an example demonstrating CopyError usage
copyerror_test.go Added tests for CopyError creation and behavior
copyerror.go Introduced the new CopyError type and its helper function
copy_test.go Updated copy tests to assert new error wrapping
copy.go Updated Copy and helper functions to use newCopyError

Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia requested a review from Copilot April 1, 2025 06:51
Copy link

@Copilot Copilot AI left a comment

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 introduces a new error type, CopyError, to provide more precise identification of error sources during copy operations. Key changes include:

  • Wrapping error returns with newCopyError to incorporate error origin (source, destination, internal).
  • Updating error expectations in tests to use errors.Is comparisons.
  • Adding tests and examples to verify and demonstrate the CopyError functionality.

Reviewed Changes

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

Show a summary per file
File Description
internal/platform/*.go Updated error handling to wrap errors with CopyError for unsupported configuration cases.
extendedcopy_test.go Renamed test function and updated error assertions to verify CopyError usage.
extendedcopy.go Modified error returns to use newCopyError, ensuring consistent error wrapping.
example_copyerror_test.go Added an example demonstrating how to inspect CopyError fields.
copyerror*.go and copy_test.go Created and tested CopyError implementation with comprehensive unit tests.
copy.go Refactored error handling in copy operations to use CopyError for designated error origins.

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>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia marked this pull request as ready for review April 2, 2025 09:25
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>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia requested a review from Copilot April 14, 2025 09:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia requested a review from Copilot April 14, 2025 09:48
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia requested a review from Copilot April 15, 2025 10:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Comments suppressed due to low confidence (1)

copy.go:273

  • [nitpick] Consider using newCopyError instead of fmt.Errorf here for consistent error wrapping and to preserve error origin information.
return fmt.Errorf("failed to check cache existence: %s: %w", desc.Digest, err)

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM with suggestions

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

@wangxiaoxuan273 wangxiaoxuan273 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

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 7963626 into oras-project:main Apr 16, 2025
9 checks passed
@Wwwsylvia Wwwsylvia deleted the structured_err branch April 16, 2025 05:14
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.

add error type return by oras.Copy
4 participants