Skip to content
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

[Question] Migration from protoc-gen-validate to protovalidate #188

Closed
rsylim804 opened this issue Mar 22, 2024 · 3 comments
Closed

[Question] Migration from protoc-gen-validate to protovalidate #188

rsylim804 opened this issue Mar 22, 2024 · 3 comments
Labels
Question Questions about the project or libraries

Comments

@rsylim804
Copy link

I am trying to use the migration tool provided under protovalidate to migrate from protoc-gen-validate but I am running into errors trying to download the git repository.

I am running go get github.com/bufbuild/[email protected] and getting this error in return:

go: github.com/bufbuild/[email protected] requires github.com/bufbuild/[email protected]: parsing go.mod:
	module declares its path as: github.com/envoyproxy/protoc-gen-validate
	        but was required as: github.com/bufbuild/protovalidate

Currently, we import protoc-gen-validate through bazel. Any ideas why I might be running into this and how to bypass this issue?

@rsylim804 rsylim804 added the Bug Something isn't working label Mar 22, 2024
@rodaine rodaine added Question Questions about the project or libraries and removed Bug Something isn't working labels Mar 25, 2024
@rodaine
Copy link
Member

rodaine commented Mar 25, 2024

Hey, @rsylim804! There's no go module at the root of this project, so you'll need to go get github.com/bufbuild/protovalidate/tools@latest to get the module that contains the migrator.

(The error you're seeing is a red-herring related to caching in the go module proxy when we initially had this project live in the protoc-gen-validate repo itself.)

@rsylim804
Copy link
Author

@rodaine Thanks for the reply! I'm running into a separate problem now trying to import protovalidate through bazel and getting it to build successfully.

Inside our BUILD file currently I have:
# gazelle:resolve proto proto buf/validate/validate.proto @protovalidate//proto/protovalidate/buf/validate:validate_proto
and
# gazelle:resolve proto go buf/validate/validate.proto @build_buf_gen_go_bufbuild_protovalidate_protocolbuffers_go//buf/validate:validate
However, I hit a cyclic dependency error trying to resolve the generated Go package for validate.proto with @org_golang_google_protobuf//cmd/protoc-gen-go:protoc-gen-go leading back to itself.

Is there a recommended way to get the migration to protovalidate working with Bazel?

@nicksnyder
Copy link
Member

Hi @rsylim804, sorry this dropped off our radar. Here are docs on how to migrate your protobuf files to from using protoc-gen-validate rules to protovalidate rules: https://buf.build/docs/migration-guides/migrate-from-protoc-gen-validate/#migration-workflow

We recently merged support for Bzlmod and Bazel 8, so not sure if that helps.

Going to close this issue out since the original problem is solved, but if you are still having trouble please file a new issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Questions about the project or libraries
Projects
None yet
Development

No branches or pull requests

3 participants