[BUG] A CEL rule naming a missing field is a RuntimeError, not a CompilationError
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- compilers
Direzione di ricerca
Start by reading check in packages/cel/src/check.ts to see the type-checking API it expects, then CelManager.compileRule in packages/protovalidate/src/cel.ts where plan(this.env, parse(rule.expression)) runs untyped. Export check from packages/cel/src/index.ts, call it before planning with this (and rules/rule for predefined rules) declared, then run the custom_rules conformance suite and drop compilation/missing_field and compilation/incorrect_type from packages/protovalidate-testing/expected-failures.yaml. Done means the missing-field rule surfaces a CompilationError at type load instead of a per-call RuntimeError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
A CEL rule that names a field the message doesn't have compiles, and every validation of the type then fails with a RuntimeError. The conformance case custom_rules compilation/missing_field expects a CompilationError, and packages/protovalidate-testing/expected-failures.yaml lists it (with compilation/incorrect_type) as an expected failure under --strict_error.
CelManager.compileRule (packages/protovalidate/src/cel.ts) builds the rule with plan(this.env, parse(rule.expression)), so nothing type-checks it. @bufbuild/cel already has a checker (check in packages/cel/src/check.ts), but packages/cel/src/index.ts doesn't export it.
Steps to Reproduce
message BrokenRequest {
option (buf.validate.message).cel = {
id: "broken"
expression: "this.missing == 1"
};
string name = 1;
}
import { create } from "@bufbuild/protobuf";
import { createValidator } from "@bufbuild/protovalidate";
import { BrokenRequestSchema } from "./gen/rules_pb.js";
const result = createValidator().validate(BrokenRequestSchema, create(BrokenRequestSchema, { name: "x" }));
console.log(result.kind, String(result.error));
Expected Behavior
error CompilationError: ..., as protovalidate-go reports when the type is first loaded.
Actual Behavior
error RuntimeError: field not found: missing, on every call.
Environment
- @bufbuild/protovalidate version: 1.3.0 (
mainhas the samecompileRule) - @bufbuild/cel version: 0.6.1
- @bufbuild/cel-spec version: 0.6.1
- Node.js version: v26.13.1
- Protobuf Compiler & Version: protoc-gen-es 2.17.0
Possible Solution
Export check from @bufbuild/cel and run it in compileRule with this (and rules/rule for predefined rules) declared as the message or rule type. A selection of a missing field, or a call with the wrong argument types, then fails at compile time, and compilation/missing_field and compilation/incorrect_type could leave the expected failures.
Additional Context
A typo in a rule is a schema error, but as a RuntimeError 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 client is created, can't tell the two apart without matching error text. So a client with a typo in a rule is created without complaint and then fails every request of that type.
- Lingua principale
- TypeScript
- Stelle
- 85
- Fork
- 14
- Merge medio
- 2m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bufbuild/protovalidate-es
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 51/100
bufbuild/protovalidate-es#218 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 55/100
bufbuild/protovalidate-es#204 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
bufbuild/protovalidate-es#188 ·
I maintainer di solito rispondono entro 1 giorno
-
Feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
bufbuild/protovalidate-es#133 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di bufbuild/protovalidate-es
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
melgarafael/DeskcommCRM#5614 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
slackapi/slack-health-score#253 ·
I maintainer di solito rispondono entro 1 giorno
-
feature needs triage site
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
owid/owid-grapher#8019 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
simstudioai/sim#10710 ·
I maintainer di solito rispondono entro 1 giorno
-
via-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno