Skip to content

Add clearer validation errors for empty or malformed routing CEL expressions #5

Description

@deepintai

Context

Routing rules in the governance plugin are CEL expressions. When a rule's expression is empty or obviously malformed, the failure today is generic and surfaces late, which makes routing misconfigurations hard to debug. A small, focused validation helper with friendly messages improves the operator experience without changing routing behavior for valid rules.

What to do

  1. Add a helper in deepintshield_server/plugins/governance/routing.go:
    func validateRoutingExpression(expr string) error
    covering:
    • Empty or whitespace-only expression -> "CEL expression cannot be empty or whitespace-only".
    • No condition operator present (none of ==, !=, in, contains, etc.) -> "CEL expression must contain at least one condition operator (==, !=, in, contains, etc.)".
  2. Call it before expression compilation in the evaluation path (e.g. within EvaluateRoutingRules / before validateCELExpression), so invalid rules fail fast with a clear message.
  3. Keep existing behavior for valid expressions unchanged.

Acceptance criteria

  • validateRoutingExpression added with the two checks and exact messages above.
  • Invoked in the routing evaluation path before CEL compilation.
  • 3-4 unit tests in routing_test.go asserting the error messages and that valid expressions pass.
  • go test ./plugins/governance/... passes.

File pointers

  • Routing engine + evaluation: deepintshield_server/plugins/governance/routing.go (EvaluateRoutingRules:79, extractRoutingVariables:312, validateCELExpression:408)
  • Tests: deepintshield_server/plugins/governance/routing_test.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions