bufbuild / protovalidate-go

Protocol Buffer Validation for Go
https://pkg.go.dev/github.com/bufbuild/protovalidate-go
Apache License 2.0
294 stars 19 forks source link

Fix panic when using a repeated field as a predefined rule #149

Closed rodaine closed 2 months ago

rodaine commented 2 months ago

Using a repeated field as a predefined rule value results in a panic, as CEL cannot convert a protoreflect.List value into a valid CEL type. This results in an error value standing in for the list's value in the expression. When attempting to optimize the expression via computing residuals, a type assertion without the guard boolean (i.e., typed := unknown.(T) instead of typed, ok := unknown.(T)) triggers the panic on this non-list error value.

This patch adds a new helper to the celext package to compute an appropriate value for any protoreflect.Value given its field descriptor.

Fixes #148

github-actions[bot] commented 2 months ago

The latest Buf updates on your PR. Results from workflow Buf / validate-protos (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed❌ failed (83)Sep 30, 2024, 11:33 PM
rodaine commented 2 months ago

Breaking changes are expected due to the transitive breaking changes from the protovalidate project.