[Feature Request] A CEL rule naming a missing field is an EvaluationError, not a CompilationError
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 20/100
Línea de trabajo
The issue names the repro (this.missing == 1 on a message with only name) and the harness at test/conformance/test_conformance.py; start by running that harness with --strict_error to watch the custom_rules compilation/missing_field case fail. From there the work is in the Rust core's rule-compilation path, where each compiled rule needs to be type-checked against the message type (and rules/rule for predefined rules) and a check failure surfaced as CompilationError rather than deferred to evaluation. Done means the repro raises CompilationError and the conformance suite passes under --strict_error.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
A CEL rule that names a field the message doesn't have is accepted when its type is first validated, and every validation of the type then raises EvaluationError. The conformance case custom_rules compilation/missing_field expects a CompilationError. It passes because test/conformance/test_conformance.py runs the harness without --strict_error, which accepts a runtime error in place of a compilation error.
Since 2.0 the rules are evaluated by cel-cpp, which has a type checker, but the error shows that the expression isn't checked against the message type when it's compiled.
Steps to Reproduce
message BrokenRequest {
option (buf.validate.message).cel = {
id: "broken"
expression: "this.missing == 1"
};
string name = 1;
}
import protovalidate
from gen.rules_pb import BrokenRequest
protovalidate.Validator().collect_violations(BrokenRequest(name="x"))
Expected Behavior
CompilationError, as protovalidate-go reports when the type is first loaded.
Actual Behavior
protovalidate.EvaluationError: error evaluating broken: no_such_field : missing, on every call.
Environment
- protovalidate-py: 2.1.0
- Python: 3.14
- Protobuf Compiler & Version: protoc-gen-py
Possible Solution
Type-check each rule with cel-cpp's checker when it's compiled, declaring this (and rules/rule for predefined rules) as the message or rule type, and raise CompilationError for a check failure. Running the conformance harness with --strict_error would then hold the behaviour in place.
Additional Context
A typo in a rule is a schema error, but as an EvaluationError it looks the same as a failure that depends on the message's values, such as a division by a field that is zero. A caller that wants to refuse a broken schema at startup, for example by validating each request type once when a service starts, can't tell the two apart without matching error text. So a service with a typo in a rule starts and then fails every request of that type.
- Lenguaje dominante
- Rust
- Estrellas
- 70
- Forks
- 13
- Merge medio
- 14 h 4 min
- PR fusionados (30 d)
- 25
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Issues similares
-
Sweep due before phase 95Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
storytold/photocraft#20056 ·
Los mantenedores suelen responder en 1 día
-
accessibility agent-ready area:android bug fleet needs-qa
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
-
A-Packaging C-Bug D-Straightforward S-Needs-Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
area:doc bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
bherbruck/solvecraft#26051 ·