Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update error in SignedEntity to be more descriptive #3233

Merged
merged 4 commits into from
Sep 10, 2023

Conversation

vishal-chdhry
Copy link
Contributor

Summary

Closes #2930

The exact error described in the issue cannot happen anymore as that behavior was changed in v2.1.0.

PR #2959 updated the old behaviour and added an if case where the error message is used in an if statement. The issue with this is that the error value is lost when ErrEntityNotFound error is created. This creates a problem where the error in SignedEntity are not descriptive enough when remoteGet function fails.

This PR will:

  • Add a function called NewEntityNotFoundError which uses the error received by remoteGet to create a new error.
  • Add a function called IsEntityNotFoundError which is used in the if statement that checks if the error message contains an ErrEntityNotFound string.

Release Note

Updated error in SignedEntity to be more descriptive

cc @znewman01

@codecov
Copy link

codecov bot commented Sep 10, 2023

Codecov Report

Merging #3233 (207124c) into main (0d48aa1) will decrease coverage by 0.02%.
Report is 2 commits behind head on main.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #3233      +/-   ##
==========================================
- Coverage   30.37%   30.35%   -0.02%     
==========================================
  Files         155      155              
  Lines        9828     9834       +6     
==========================================
  Hits         2985     2985              
- Misses       6397     6403       +6     
  Partials      446      446              
Files Changed Coverage Δ
cmd/cosign/cli/sign/sign.go 14.25% <0.00%> (ø)
pkg/oci/remote/remote.go 36.77% <0.00%> (-1.49%) ⬇️

Copy link
Contributor

@znewman01 znewman01 left a comment

Choose a reason for hiding this comment

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

Thanks for this change! Overall looks good, I have a couple of Go-specific requests.

pkg/oci/remote/remote.go Outdated Show resolved Hide resolved
pkg/oci/remote/remote.go Outdated Show resolved Hide resolved
@znewman01 znewman01 enabled auto-merge (squash) September 10, 2023 16:43
@znewman01 znewman01 merged commit 86252aa into sigstore:main Sep 10, 2023
28 checks passed
@github-actions github-actions bot added this to the v2.3.0 milestone Sep 10, 2023
lance pushed a commit to securesign/cosign that referenced this pull request Sep 25, 2023
…3233)

* fix: add func to generate `entity not found` error

Signed-off-by: Vishal Choudhary <[email protected]>

* fix: update format specifier in fmt.Errorf

Signed-off-by: Vishal Choudhary <[email protected]>

* feat: make ErrEntityNotFound error message less common

Signed-off-by: Vishal Choudhary <[email protected]>

* feat: make EntityNotFoundError a first-class error

Signed-off-by: Vishal Choudhary <[email protected]>

---------

Signed-off-by: Vishal Choudhary <[email protected]>
@cpanato cpanato modified the milestones: v2.3.0, v2.2.1 Nov 16, 2023
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.

Better error messages for unauthorized PATs to private packages
3 participants