Skip to content

Update 'buf mod update' to check digest changes#1874

Merged
pkwarren merged 10 commits intomainfrom
pkw/TCN-1033-mod-update-check-digest
Mar 1, 2023
Merged

Update 'buf mod update' to check digest changes#1874
pkwarren merged 10 commits intomainfrom
pkw/TCN-1033-mod-update-check-digest

Conversation

@pkwarren
Copy link
Member

If 'buf mod update' runs and resolves to the same module identity and commit, it should error out if the digest doesn't match what is recorded in the buf.lock file. While unlikely, this may indicate that a module has changed since last resolved against the BSR.

If 'buf mod update' runs and resolves to the same module identity and
commit, it should error out if the digest doesn't match what is recorded
in the buf.lock file. While unlikely, this may indicate that a module
has changed since last resolved against the BSR.
if err := bufmoduleref.PutDependencyModulePinsToBucket(ctx, readWriteBucket, dependencyModulePins); err != nil {
var inconsistentDigestErr bufmoduleref.InconsistentDigestError
if errors.As(err, &inconsistentDigestErr) {
return err
Copy link
Member Author

Choose a reason for hiding this comment

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

The mechanics of this can change, but what I'm trying to avoid here is printing out an error message that indicates it is an internal error that needs to be reported to Buf's issues page for a well known error.

@pkwarren pkwarren marked this pull request as ready for review March 1, 2023 17:33
@pkwarren pkwarren requested a review from twilly March 1, 2023 17:34
Copy link
Member

@unmultimedio unmultimedio left a comment

Choose a reason for hiding this comment

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

Just nits, non blocking, nice work!

Comment on lines +413 to +415
if _, err := manifest.NewDigestFromString(dep.Digest); err != nil {
continue
}
Copy link
Member

Choose a reason for hiding this comment

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

Worth to log a warning about replacing an invalid digest?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could but I don't know what value it would have. I guess we could conceivably have really old lock files that still have a b3 digest in them, and replacing it shouldn't trigger warnings.

@pkwarren pkwarren requested review from bufdev and unmultimedio March 1, 2023 20:11
Copy link
Contributor

@twilly twilly left a comment

Choose a reason for hiding this comment

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

LGTM :)

@pkwarren pkwarren merged commit a2cb10a into main Mar 1, 2023
@pkwarren pkwarren deleted the pkw/TCN-1033-mod-update-check-digest branch March 1, 2023 23:01
Monirul1 pushed a commit to Monirul1/buf that referenced this pull request Apr 30, 2023
If 'buf mod update' runs and resolves to the same module identity and
commit, it should error out if the digest doesn't match what is recorded
in the buf.lock file. While unlikely, this may indicate that a module
has changed since last resolved against the BSR.
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.

4 participants