Unused import detection is broken in protoc-gen-buf-lint
when the image contains an incompatible version of protovalidate than the one buf was compiled with
#3306
Labels
Bug
Something isn't working
GitHub repository with your minimal reproducible example (do not fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)
https://github.com/jchadwick-buf/protoc-gen-buf-lint-unused-ext-import-issue
Commands
Output
--buf-lint_out: test/c.proto:5:1:Import "test/a.proto" is unused.
Expected Output
I expect no lint failures.
Anything else?
This is caused because
protoplugin
usesproto.Unmarshal
, using the defaultproto.UnmarshalOptions
. This causes theResolver
to beprotoregistry.GlobalTypes
, resulting in all of the extensions from gencode imported by the Buf CLI code being prematurely resolved before the reparse phase. In this case, it happens due toprotovalidate
.This is blocking bufbuild/protovalidate#246. When the import tracker for
protoc-gen-buf-lint
tries to mark imports as used, it tries to mark all of the extensions for options as used, but it hits an unexpected case when it sees the extensions for the shared protovalidate constraint, because it resolves to the fullnamebuf.validate.priv.field
, but the PR renames thepriv
package toshared
.Fixing this will require some kind of modification to
protoplugin
, but a change that will fix this issue is very likely to change the behavior in other cases, so I think this warrants the creation of a new option inprotoplugin
.The text was updated successfully, but these errors were encountered: