Error when buf.yaml dep is missing from buf.lock#4529
Open
stefanvanburen wants to merge 1 commit intomainfrom
Open
Error when buf.yaml dep is missing from buf.lock#4529stefanvanburen wants to merge 1 commit intomainfrom
stefanvanburen wants to merge 1 commit intomainfrom
Conversation
Contributor
|
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
4ec4076 to
51f821c
Compare
When a module is added to buf.yaml deps but buf dep update has not been run, the module is absent from buf.lock entirely. Previously this caused two bad outcomes depending on whether any proto files imported from the missing dep: - If proto files imported from it: a confusing protoc-level "file not found" error with no mention of buf.lock or what to do. - If proto files did not yet import from it: MalformedDepsForWorkspace would flag it as MalformedDepTypeUnused, suggesting the user remove the dep — the opposite of the right advice. Fix this by checking, during workspace construction, that every module declared in buf.yaml deps has a corresponding entry in buf.lock. If any are missing, return an actionable error immediately: "buf.testing/acme/extension" declared in buf.yaml deps but not present in buf.lock; run "buf dep update" to update the lock file The check is added to both the v1 and v2 workspace construction paths in workspace_provider.go and requires no network call — it is a pure comparison of module full names between the two config files. Two test cases are added: one where the missing dep is not yet used in any proto file (previously: silent success with a misleading "unused" warning), and one where the missing dep is actively imported (previously: cryptic "file not found" from the compiler).
51f821c to
533fe37
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a module is added to buf.yaml deps but buf dep update has not been
run, the module is absent from buf.lock entirely. Previously this caused
two bad outcomes depending on whether any proto files imported from the
missing dep:
found" error with no mention of buf.lock or what to do.
would flag it as MalformedDepTypeUnused, suggesting the user remove
the dep — the opposite of the right advice.
Fix this by checking, during workspace construction, that every module
declared in buf.yaml deps has a corresponding entry in buf.lock. If any
are missing, return an actionable error immediately:
"buf.testing/acme/extension" declared in buf.yaml deps but not present
in buf.lock; run "buf dep update" to update the lock file
The check is added to both the v1 and v2 workspace construction paths
in workspace_provider.go and requires no network call — it is a pure
comparison of module full names between the two config files.
Two test cases are added: one where the missing dep is not yet used in
any proto file (previously: silent success with a misleading "unused"
warning), and one where the missing dep is actively imported (previously:
cryptic "file not found" from the compiler).