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

feat: Update error message #660

Closed
wants to merge 1 commit into from

Conversation

laurentsimon
Copy link
Contributor

No description provided.

Signed-off-by: laurentsimon <laurentsimon@google.com>
@laurentsimon laurentsimon enabled auto-merge (squash) July 18, 2023 00:24
@@ -132,7 +132,11 @@ func IsValidBuilderTag(ref string, testing bool) error {
if testing {
// Tags on trusted repositories should be a valid semver with version
// core including all three parts and no build identifier.
versionCore := strings.Split(pin, "-")[0]
parts := strings.Split(pin, "-")
if len(parts) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'm pretty sure strings.Split will never return a slice with a length of zero (if sep is non-empty, which it is in this case). Was this an issue you actually encountered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just read the doc and you're right. Will revert.

@@ -419,6 +423,10 @@ func VerifyVersionedTag(prov iface.Provenance, expectedTag string) error {
return err
}

if ref == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Contributor Author

@laurentsimon laurentsimon Jul 18, 2023

Choose a reason for hiding this comment

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

i ran into an issue where the error message just gave empty results, because ref is empty. That happened when a user passes --source-versioned-tag but the build happened not on a release trigger.

Copy link
Member

@ianlewis ianlewis Jul 18, 2023

Choose a reason for hiding this comment

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

Ok, I think you can move this check to utils.ValidateGitRef and provide a better error message there.

Or you can do like you did above and check the tag returned by TagFromGitRef since I think this code will fail if ref is just the refs/tags/ prefix without an actual tag name.

verifiers/internal/gha/provenance.go Show resolved Hide resolved
@@ -396,6 +396,10 @@ func VerifyTag(prov iface.Provenance, expectedTag string) error {
}

tag, err := utils.TagFromGitRef(ref)
if tag == "" {
return fmt.Errorf("verifying tag: %w: no tag found in provenance", serrors.ErrorMismatchTag)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("verifying tag: %w: no tag found in provenance", serrors.ErrorMismatchTag)
return fmt.Errorf("verifying tag: %w: empty tag name in provenance", serrors.ErrorMismatchTag)

auto-merge was automatically disabled August 6, 2023 22:44

Pull request was closed

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.

2 participants