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
My motivation is to build support for protokt (alternate protobuf codegen + runtime) in protovalidate-java, which uses CEL.
I think I've encountered two independent bugs in the planner runtime; both surface when CEL navigates a com.google.protobuf.Message whose conversion goes through ProtoCelValueConverter:
proto fixed32/fixed64 fields resolve as signed int, breaking uint overloads: the CEL spec maps proto fixed32/fixed64 to CEL uint, and the CelValue path via ProtoCelValueConverter.fromProtoMessageFieldToCelValue does not: it has cases for UINT32/UINT64 but not FIXED32/FIXED64, so those fall through to normalizePrimitive and surface as Integer/Long.
FieldMask-typed fields can't be navigated as messages: BaseProtoCelValueConverter.fromWellKnownProto converts FieldMask to a comma-separated string of its paths, which is different from cel-go and cel-java's ProtoLiteAdapter.adaptValueToWellKnownProto.
To Reproduce
Check which components this affects:
parser
checker
runtime
Reproducers (in Kotlin to get dependencies inline):
@file:Repository("https://repo1.maven.org/maven2")
@file:DependsOn("dev.cel:cel:0.13.0")
@file:DependsOn("com.google.protobuf:protobuf-java:4.30.1")
importcom.google.protobuf.DescriptorProtos.DescriptorProtoimportcom.google.protobuf.DescriptorProtos.FieldDescriptorProtoimportcom.google.protobuf.DescriptorProtos.FileDescriptorProtoimportcom.google.protobuf.Descriptors.FileDescriptorimportcom.google.protobuf.DynamicMessageimportdev.cel.bundle.CelFactoryimportdev.cel.common.types.StructTypeReference// A minimal one-field message: `Msg { fixed32 f = 1; }`, built from a runtime// descriptor so the reproducer needs no .proto compilation.val fileProto =FileDescriptorProto.newBuilder()
.setName("repro.proto")
.setSyntax("proto3")
.addMessageType(
DescriptorProto.newBuilder()
.setName("Msg")
.addField(
FieldDescriptorProto.newBuilder()
.setName("f")
.setNumber(1)
.setType(FieldDescriptorProto.Type.TYPE_FIXED32)
.setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
)
)
.build()
val fileDescriptor =FileDescriptor.buildFrom(fileProto, arrayOf())
val msgDescriptor = fileDescriptor.findMessageTypeByName("Msg")
val cel =CelFactory.plannerCelBuilder()
.addMessageTypes(msgDescriptor)
.addVar("msg", StructTypeReference.create("Msg"))
.build()
// The checker types a proto fixed32 field as CEL `uint`; `msg.f > 5u` type-checks.val ast = cel.compile("msg.f > 5u").ast
val program = cel.createProgram(ast)
val msg =DynamicMessage.newBuilder(msgDescriptor)
.setField(msgDescriptor.findFieldByNumber(1), 6)
.build()
val result = program.eval(mapOf("msg" to msg))
println("msg.f > 5u -> $result")
check(result ==true) { "expected true" }
println("OK")
Describe the bug
My motivation is to build support for protokt (alternate protobuf codegen + runtime) in protovalidate-java, which uses CEL.
I think I've encountered two independent bugs in the planner runtime; both surface when CEL navigates a
com.google.protobuf.Messagewhose conversion goes throughProtoCelValueConverter:proto
fixed32/fixed64fields resolve as signed int, breakinguintoverloads: the CEL spec maps protofixed32/fixed64to CELuint, and theCelValuepath viaProtoCelValueConverter.fromProtoMessageFieldToCelValuedoes not: it has cases forUINT32/UINT64but notFIXED32/FIXED64, so those fall through tonormalizePrimitiveand surface asInteger/Long.FieldMask-typed fields can't be navigated as messages:BaseProtoCelValueConverter.fromWellKnownProtoconvertsFieldMaskto a comma-separated string of its paths, which is different from cel-go and cel-java'sProtoLiteAdapter.adaptValueToWellKnownProto.To Reproduce
Check which components this affects:
Reproducers (in Kotlin to get dependencies inline):
Throws
dev.cel.runtime.CelEvaluationException: evaluation error at <input>:6: No matching overload for function '_>_'. Overload candidates: greater_uint64.. Potential fix: Handle FIXED32/FIXED64 as unsigned in ProtoCelValueConverter #1073Throws
dev.cel.runtime.CelEvaluationException: evaluation error at <input>:5: Error resolving field 'paths'. Field selections must be performed on messages or maps.. Potential fix: Preserve FieldMask as a message in the CelValue runtime path #1074Additional context
For the full context see bufbuild/protovalidate-java#202 and open-toast/protokt#402