Skip to content

Display warning when reading a buf.lock with a b3 digest#2520

Merged
oliversun9 merged 13 commits intomainfrom
osun/display-warning-when-reading-b3-digest
Nov 9, 2023
Merged

Display warning when reading a buf.lock with a b3 digest#2520
oliversun9 merged 13 commits intomainfrom
osun/display-warning-when-reading-b3-digest

Conversation

@oliversun9
Copy link
Contributor

@oliversun9 oliversun9 commented Oct 27, 2023

Right now, if the CLI reads a buf.lock with a b3 digest, it treats digest as empty. This PR displays a warning when it's encountered.

Added a check that reads the lock file and checks whether any digest starts with b1- or b3- to

  • getSourceModuleConfig, called by buf beta graph, buf beta price, buf beta stats, buf build, buf convert , buf export, buf format, buf generateand buf lint, when the source / input is a module directory or workspace directory.
  • run in buf push.

Copy link
Member

@bufdev bufdev left a comment

Choose a reason for hiding this comment

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

The proliferation of loggers here would lead me to think there's a cleaner way to do this, we're adding logger in places we don't want it. Why not just read the lock file at some top level and print a warning if b3 is found, as opposed to weaving this through all the logic? A buflock.CheckDeprecatedDigests function you can call?

Copy link
Member

@bufdev bufdev left a comment

Choose a reason for hiding this comment

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

Yea this looks way better :-) Are you sure these are the only places we need to call it?

@oliversun9
Copy link
Contributor Author

Yea this looks way better :-) Are you sure these are the only places we need to call it?

I think all commands that read a buf.lock are covered. I updated the PR description to give the full list of commands where this warning can be displayed.

Copy link
Contributor

@saquibmian saquibmian left a comment

Choose a reason for hiding this comment

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

There's also buf alpha sync here. That one's a little tricky because we scan commits in the past and we don't want to show the warning for all of them. We probably want to warn based on some timestamp? If commit was created after Nov 1st? I don't know how @bufdev feels about that, though.

@oliversun9
Copy link
Contributor Author

oliversun9 commented Nov 1, 2023

There's also buf alpha sync here. That one's a little tricky because we scan commits in the past and we don't want to show the warning for all of them. We probably want to warn based on some timestamp? If commit was created after Nov 1st? I don't know how @bufdev feels about that, though.

What if we use a global variable to keep track of whether this warning has been printed, so that we only print it once? (or sync.Once)

@bufdev
Copy link
Member

bufdev commented Nov 1, 2023

What if we use a global variable

Mutable global variables to signal state are banned

@doriable
Copy link
Member

doriable commented Nov 2, 2023

That one's a little tricky because we scan commits in the past and we don't want to show the warning for all of them. We probably want to warn based on some timestamp? If commit was created after Nov 1st?

Kind of inclined to say that if you're using buf sync, you shouldn't see warnings of this nature at all. And let's say we implement "after a certain date (e.g. Nov. 1)", that commit will still be in their history, so even if they fix the issue, if they ever resync to a different repo, for example, they'll see it. I might leave buf sync out of this one, tbh. But yeah, @bufdev, I'll let you make the final call on this ^^"

@saquibmian
Copy link
Contributor

if you're using buf sync, you shouldn't see warnings of this nature at all

The point of this is to give people an indication that they should migrate off of b3 digests. How do you think we should do that for repositories using buf sync?

As an alternative to all of this, we could instead show the warning in the BSR UI? It would be visible only to org members/admins. They are more likely to see it anyway, as users aren't in the habit of seeing warnings in CI runs.

@doriable
Copy link
Member

doriable commented Nov 7, 2023

As an alternative to all of this, we could instead show the warning in the BSR UI? It would be visible only to org members/admins. They are more likely to see it anyway, as users aren't in the habit of seeing warnings in CI runs.

Yeah, I think I'm more in agreeance with that sort of approach, because yeah, exactly, dealing with warnings in a CI run that aren't outright failures are often not priorities. And also, it's something they would need to handle by checking updates into source anyway (same with any dependency upgrade).

@saquibmian
Copy link
Contributor

We chatted about this, and decided that we're not going to warn from sync, largely because it's highly likely that no one sees those anyway. The high value places to warn are build and lint, which are done.

Separately, we will consider a warning in the BSR UI, visible to repository members.

@oliversun9 oliversun9 requested a review from saquibmian November 9, 2023 15:22
@oliversun9 oliversun9 merged commit b38f0f7 into main Nov 9, 2023
@oliversun9 oliversun9 deleted the osun/display-warning-when-reading-b3-digest branch November 9, 2023 16:01
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