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

generated file name does not conform to protobuf generation specification and module option broken on Windows #611

Closed
nvx opened this issue Jul 12, 2022 · 0 comments

Comments

@nvx
Copy link
Contributor

nvx commented Jul 12, 2022

When running protoc-gen-validate on Windows, which uses a \ instead of / as the file path separator, the following warnings are generated with buf.build:

Warning: Generated file name "some\\package\\common.pb.validate.go" does not conform to the Protobuf generation specification. Note that the file name must be relative, use "/" instead of "\", and not use "." or ".." as part of the file name. Buf will continue without error here, but please raise an issue with the maintainer of the plugin and reference https://github.com/protocolbuffers/protobuf/blob/95e6c5b4746dd7474d540ce4fb375e3f79a086f8/src/google/protobuf/compiler/plugin.proto#L122

While the warning itself is annoying, the real issue is that this breaks the use of the module parameter. Normally specifying module=some/package would strip the some/package prefix from the path, but due to the paths having a backslash instead this does not work. Specifying module=some\package\ achieves the desired outcome, but this breaks portability. Also note that an additional trailing backslash is needed as the strings.TrimLeft(..., "/") in the generator code also doesn't work.

https://github.com/envoyproxy/protoc-gen-validate/blob/978fc60fbe180f2b8d4b8577a7399714dfec2558/module/validate.go#L48-L54

I believe this is fixed in the protoc-gen-star package already due to lyft/protoc-gen-star#97, but it doesn't look like a new release has been cut since that PR was merged. Would updating to a git hash version be acceptable? I'm happy to submit a PR if needed.

nvx added a commit to nvx/protoc-gen-validate that referenced this issue Jul 12, 2022
nvx added a commit to nvx/protoc-gen-validate that referenced this issue Jul 12, 2022
nvx added a commit to nvx/protoc-gen-validate that referenced this issue Jul 12, 2022
…ufbuild#611

Signed-off-by: Tiernan Messmer <tiernan.messmer@jcu.edu.au>
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

No branches or pull requests

2 participants