Skip to content

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

Merged
merged 3 commits into from
Jul 25, 2025

Conversation

emcfarlane
Copy link
Contributor

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

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.
@emcfarlane emcfarlane requested a review from doriable June 23, 2025 15:22
Copy link
Contributor

github-actions bot commented Jun 23, 2025

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJul 21, 2025, 4:28 PM

@@ -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") {
Copy link
Member

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.

Copy link
Contributor Author

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 {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@doriable doriable left a 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.

@emcfarlane emcfarlane merged commit d3d9b86 into main Jul 25, 2025
10 checks passed
@emcfarlane emcfarlane deleted the ed/fixAgainstRegistryEmptyDefault branch July 25, 2025 18:30
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.

3 participants