-
Notifications
You must be signed in to change notification settings - Fork 19
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
[BUG] Reference nested fields on field type validation causes unexpected error #174
Comments
Hi, @fenos! I'm sorry you're getting an unexpected error. I attempted to reproduce your issue in https://github.com/bufbuild/protovalidate-go/compare/rodaine/issue-174, but pv-go behaved as you'd expect. This also matches the conformance test cases that cover this as well. What version of pv-go are you using? If you're using buf for code generation, can you share your |
Hey @rodaine thanks a lot for checking this out. It is very strange that it is not working. Could it be because of some import order? Versions I'm using:
Here are the bufs files: buf.yaml # For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
version: v2
lint:
use:
- STANDARD
except:
- PACKAGE_DIRECTORY_MATCH
breaking:
use:
- FILE
deps:
- buf.build/googleapis/googleapis:e93e34f48be043dab55be31b4b47f458
- buf.build/bufbuild/protovalidate buf.gen.yaml version: v2
plugins:
# GO
- local: protoc-gen-go
out: gen/go/
opt: paths=source_relative
- local: protoc-gen-connect-go
out: gen/go/
opt: paths=source_relative
# JS
- local: protoc-gen-es
out: gen/es/
# Also generate any imported dependencies
include_imports: true
# Add more plugin options here
opt: target=ts
- local: protoc-gen-connect-query
out: gen/es/
opt: target=ts |
@rodaine ah! the issue seemed to be caused by the option |
Using source_relative is usually the right choice. Since you're not using managed mode, you may also want to specify Are you generating the dependencies as well or just your protos? Imports in the generated code for protovalidate should refer to the |
@rodaine interesting thanks! // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.1
// protoc (unknown)
// source: schema/user/v1/user.proto
package v1
import (
_ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
date "google.golang.org/genproto/googleapis/type/date"
latlng "google.golang.org/genproto/googleapis/type/latlng"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
Actually, the issue doesn't seem related to the source path. I tried adding it and removing it but doesn't make any difference. |
Mmmh it turned out i was using an old version of protovalidate-go (v.0.3.0) no idea how it got pulled this old version of protovalidate-go. As soon as I updated to latest it all works consistently 👍 |
Description
When i try accessing a nested value from a field level validation using CEL, I get the following error:
Steps to Reproduce
Expected Behavior
I can access normally nested values using
this.
Actual Behavior
Produces the error mentioned above:
Additional Context
It seems to be working if moving the validation to a message type validation instead of field. But it doesn't seem right to need to have it on the message since it's not accessing any other property outside the field itself
The text was updated successfully, but these errors were encountered: