{"record":{"id":"d72e55f4945b4b11","repo":"cilium/cilium","slug":"error-building-cel-program-w","errorCode":null,"errorMessage":"error building CEL program: %w","messagePattern":"error building CEL program: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubble/filters/cel_expression.go","lineNumber":82,"sourceCode":"\t\t\t\"got %q, wanted %q result type\",\n\t\t\tchecked.OutputType(), celType)\n\t}\n\treturn ast, nil\n}\n\nfunc filterByCELExpression(ctx context.Context, log *slog.Logger, exprs []string) (FilterFunc, error) {\n\tvar programs []cel.Program\n\tfor _, expr := range exprs {\n\t\t// we want filters to be boolean expressions, so check the type of the\n\t\t// expression before proceeding\n\t\tast, err := compile(celEnv, expr, cel.BoolType)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error compiling CEL expression: %w\", err)\n\t\t}\n\n\t\tprg, err := celEnv.Program(ast)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error building CEL program: %w\", err)\n\t\t}\n\t\tprograms = append(programs, prg)\n\t}\n\n\treturn func(ev *v1.Event) bool {\n\t\tfor _, prg := range programs {\n\t\t\tout, _, err := prg.ContextEval(ctx, map[string]any{\n\t\t\t\tflowVariableName: ev.GetFlow(),\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(\"error running CEL program\", logfields.Error, err)\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tv, err := out.ConvertToNative(goBoolType)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(\"invalid conversion in CEL program\", logfields.Error, err)\n\t\t\t\treturn false","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/hubble/filters/cel_expression.go#L64-L100","documentation":"filterByCELExpression wraps errors from celEnv.Program(ast), the stage that binds a checked AST into an executable program. This fires when the AST is valid but cannot be turned into a program (e.g. unsupported declarations or environment misconfiguration). Thrown at pkg/hubble/filters/cel_expression.go:82.","triggerScenarios":"celEnv.Program(ast) returning an error after compile() succeeded — typically when the CEL environment lacks needed declarations/functions referenced at program-build time.","commonSituations":"Custom CEL environments missing function declarations used by the expression; library version mismatches between the CEL runtime and declared functions.","solutions":["Read the wrapped cause for which declaration/option the program builder rejected","Ensure the cel.Env used to build the program is the same one that checked the AST","Register any custom functions/declarations the expression uses via celenv options","Upgrade/downgrade Cilium if a known CEL library incompatibility is involved"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure the AST compiles to a program with the same env before building filters\nast, _ := celEnv.Parse(expr)\nchk, iss := celEnv.Check(ast)\nif iss == nil || iss.Err() == nil {\n    if _, perr := celEnv.Program(chk); perr != nil { return perr }\n}","typeGuard":null,"tryCatchPattern":"prg, err := celEnv.Program(ast)\nif err != nil {\n    return nil, fmt.Errorf(\"CEL program build failed for %q: %w\", expr, err)\n}","preventionTips":["Use one cel.Env instance for both Check and Program","Register all custom functions/declarations in the env before parsing expressions","Keep CEL library versions consistent across the Cilium build"],"tags":["cel","filter","program","compilation"],"backgroundTag":"cel-program-build-error","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}