-
Notifications
You must be signed in to change notification settings - Fork 314
Fix breaking against registry for empty repositories #3896
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
Conversation
This fixes `buf breaking --against-registry` for newly created modlues when the default branch contains no commits. Treat the module as empty, therefore no breaking changes.
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
@@ -258,6 +261,15 @@ func run( | |||
bufctl.WithConfigOverride(flags.AgainstConfig), | |||
) | |||
if err != nil { | |||
if connect.CodeOf(err) == connect.CodeFailedPrecondition && strings.Contains(err.Error(), "no commits in the default label") { |
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.
There must be a way to do this that is structured using ErrorDetails. Doing a string match on an error message doesn't seem right.
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.
Pushed a workaround for now. Will update the registry-protos to annotate the use of ErrorDetails and update the Registry to use them.
}, | ||
), | ||
); err != nil { | ||
if connect.CodeOf(err) == connect.CodeFailedPrecondition { |
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.
Why is an empty response returning failed precondition? Why not not found?
Also I would probably use list with a page size of 1, and see if the returned list has 0 elements.
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.
Failed precondition is due to being able to resolve the resource (a Module), but not able to return a Commit for it. The ListCommits endpoint was not used as it needs to resolve the default label, then using List would return a 404, as the default Label resource does not exist, and can't resolve.
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.
This looks good to me, thank you! As discussed and noted in the comment, once error details become available, the check will be updated.
This fixes
buf breaking --against-registry
for newly created modlues when the default branch contains no commits. Treat the module as empty, therefore no breaking changes.Related to #3641