You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explicit-presence double fields (and items under editions) skip finite#111
protoc-gen-protovalidate-buffa v0.10.5 does not emit the finite rule of DoubleRules for a field with explicit presence. That covers every singular
field of a file written with editions (2023, 2024), and a proto3 optional double. Under editions it is also dropped for repeated items. The same file
in plain proto3 gets the check. This looks like the same family as #103
(explicit-presence enum fields skip defined_only, const, in and not_in). Since gt/gte compare with <=/<, a NaN or an infinity then
passes validate() on a field that says finite: true.
Reproduction
proto/t/v1/t.proto. The first line is varied below; the rest is the same.
protoc-gen-protovalidate-buffa 0.10.5, the release binary;
buf 1.75.0;
buf/validate/validate.proto from protovalidate 1.2.2.
The rule ids found in the generated t.v1.t.validate.rs:
First line
double.finite
double.gt
double.gte
syntax = "proto3";
4
2
2
edition = "2023";
0
2
2
edition = "2024";
0
2
2
So under editions, gt and gte are kept and finite is dropped. This
holds both when finite is the only rule (only) and for repeated items
(items). With proto3 and optional double only = 1 / optional double both = 2 (same rules), the result is 0 double.finite and
2 double.gt: explicit presence alone is enough.
Expected
The same checks whatever the syntax or edition of the file. A NaN or an
infinity in only, both or items should fail validate().
Workaround we use
A field-level CEL rule is generated correctly under edition 2024: !this.isNan() && !this.isInf(), and for a repeated field this.all(w, !w.isNan() && !w.isInf()).
Disclosure: Claude Opus 5.5 found this bug, narrowed it down to explicit presence, and drafted this Discussion.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
protoc-gen-protovalidate-buffav0.10.5 does not emit thefiniterule ofDoubleRulesfor a field with explicit presence. That covers every singularfield of a file written with editions (2023, 2024), and a proto3
optional double. Under editions it is also dropped for repeated items. The same filein plain proto3 gets the check. This looks like the same family as #103
(explicit-presence enum fields skip
defined_only,const,inandnot_in). Sincegt/gtecompare with<=/<, a NaN or an infinity thenpasses
validate()on a field that saysfinite: true.Reproduction
proto/t/v1/t.proto. The first line is varied below; the rest is the same.buf.gen.yaml:The versions are:
protoc-gen-protovalidate-buffa0.10.5, the release binary;buf/validate/validate.protofrom protovalidate 1.2.2.The rule ids found in the generated
t.v1.t.validate.rs:double.finitedouble.gtdouble.gtesyntax = "proto3";edition = "2023";edition = "2024";So under editions,
gtandgteare kept andfiniteis dropped. Thisholds both when
finiteis the only rule (only) and for repeated items(
items). With proto3 andoptional double only = 1/optional double both = 2(same rules), the result is 0double.finiteand2
double.gt: explicit presence alone is enough.Expected
The same checks whatever the syntax or edition of the file. A NaN or an
infinity in
only,bothoritemsshould failvalidate().Workaround we use
A field-level CEL rule is generated correctly under edition 2024:
!this.isNan() && !this.isInf(), and for a repeated fieldthis.all(w, !w.isNan() && !w.isInf()).Disclosure: Claude Opus 5.5 found this bug, narrowed it down to explicit presence, and drafted this Discussion.
All reactions