-
Notifications
You must be signed in to change notification settings - Fork 49
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
Conversation
@@ -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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
Pull request was closed
No description provided.