Skip to content

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

Merged
znewman01 merged 4 commits intosigstore:mainfrom
vishal-chdhry:update-signed-entity-error
Sep 10, 2023
Merged

fix: update error in SignedEntity to be more descriptive#3233
znewman01 merged 4 commits intosigstore:mainfrom
vishal-chdhry:update-signed-entity-error

Conversation

@vishal-chdhry
Copy link
Copy Markdown
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

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@codecov
Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread pkg/oci/remote/remote.go Outdated
Comment thread pkg/oci/remote/remote.go Outdated
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@znewman01 znewman01 enabled auto-merge (squash) September 10, 2023 16:43
@znewman01 znewman01 merged commit 86252aa into sigstore:main Sep 10, 2023
@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 <sendtovishalchoudhary@gmail.com>

* fix: update format specifier in fmt.Errorf

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>

* feat: make ErrEntityNotFound error message less common

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>

* feat: make EntityNotFoundError a first-class error

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>

---------

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@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