Description
The final step in the example in the README fails due to an import error.
Steps to Reproduce
- Set up folder structure
.
|
|____ gen/
| |____ ... # will be filled
|
|____ examples/
| |____ transaction.proto # contains example
|
|____ buf.yaml
|
|____ buf.gen.yaml
|
|____ buf.work.yaml
- Set the file contents
# buf.yaml
version: v1
deps:
- buf.build/bufbuild/protovalidate
# buf.work.yaml
version: v1
directories:
- examples
# buf.gen.yaml
version: v1
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/python:v23.4
out: gen
// examples/transaction.proto example from README.md
syntax = "proto3";
package my.package;
import "google/protobuf/timestamp.proto";
import "buf/validate/validate.proto";
message Transaction {
uint64 id = 1 [(buf.validate.field).uint64.gt = 999];
google.protobuf.Timestamp purchase_date = 2;
google.protobuf.Timestamp delivery_date = 3;
string price = 4 [(buf.validate.field).cel = {
id: "transaction.price",
message: "price must be positive and include a valid currency symbol ($ or £)",
expression: "(this.startswith('$') or this.startswith('£')) and float(this[1:]) > 0"
}];
option (buf.validate.message).cel = {
id: "transaction.delivery_date",
message: "delivery date must be after purchase date",
expression: "this.delivery_date > this.purchase_date"
};
}
- Run from root folder
- Run from root folder
buf generate buf.build/bufbuild/protovalidate
- Run from root folder
buf generate --include-imports
Expected Behaviour
Should generate the python models.
Actual Behaviour
Everything up to step 4 works. In step 5 I get the error
examples/transaction.proto:6:8:buf/validate/validate.proto: does not exist
Screenshots/Logs
Environment
- Operating System: OSX
- Version: macOS 13.5.2
- Compiler/Toolchain: python 3.11, Buf cli v1.27.0
- Protobuf Compiler & Version: Buf cli v1.27.0, protoc v24.3
- Protoc-gen-validate Version: 1.0.2
- Protovalidate Version: 0.2.1
Also have python packages
- protobuf==4.24.4
- grpcio-tools==1.59.0
Possible Solution
I think I followed the instructions as closely as possible. If not, please let me know.
Either way, it would be nice if this repository had a simple example (a folder containing one single *.proto file + the buf*.yaml files) that worked "out of the box" (assuming Buf cli is installed).
Description
The final step in the example in the README fails due to an import error.
Steps to Reproduce
Expected Behaviour
Should generate the python models.
Actual Behaviour
Everything up to step 4 works. In step 5 I get the error
Screenshots/Logs
Environment
Also have python packages
Possible Solution
I think I followed the instructions as closely as possible. If not, please let me know.
Either way, it would be nice if this repository had a simple example (a folder containing one single *.proto file + the buf*.yaml files) that worked "out of the box" (assuming Buf cli is installed).