{"record":{"id":"697d90a9aa3ef0e0","repo":"amir20/dozzle","slug":"failed-to-compile-event-expression-w-697d90","errorCode":null,"errorMessage":"failed to compile event expression: %w","messagePattern":"failed to compile event expression: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notification/types.go","lineNumber":199,"sourceCode":"\t\tprogram, err := expr.Compile(s.LogExpression, expr.Env(types.NotificationLog{}))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to compile log expression: %w\", err)\n\t\t}\n\t\ts.LogProgram = program\n\t}\n\n\tif s.MetricExpression != \"\" {\n\t\tprogram, err := expr.Compile(s.MetricExpression, expr.Env(types.NotificationStat{}))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to compile metric expression: %w\", err)\n\t\t}\n\t\ts.MetricProgram = program\n\t}\n\n\tif s.EventExpression != \"\" {\n\t\tprogram, err := expr.Compile(s.EventExpression, expr.Env(types.NotificationEvent{}))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to compile event expression: %w\", err)\n\t\t}\n\t\ts.EventProgram = program\n\t}\n\n\treturn nil\n}\n\n// DispatcherConfig represents a dispatcher configuration\ntype DispatcherConfig struct {\n\tID       int               `json:\"id\" yaml:\"id\"`\n\tName     string            `json:\"name\" yaml:\"name\"`\n\tType     string            `json:\"type\" yaml:\"type\"` // \"webhook\" or \"cloud\"\n\tURL      string            `json:\"url,omitempty\" yaml:\"url,omitempty\"`\n\tTemplate string            `json:\"template,omitempty\" yaml:\"template,omitempty\"` // Go template for custom payload format\n\tHeaders  map[string]string `json:\"headers,omitempty\" yaml:\"headers,omitempty\"`   // Custom HTTP headers\n\tPrefix   string            `json:\"prefix,omitempty\" yaml:\"-\"`                    // Cloud dispatcher API key prefix (not persisted)\n}\n","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/notification/types.go#L181-L217","documentation":"CompileExpressions compiles EventExpression with expr against types.NotificationEvent. Invalid syntax or unknown identifiers fail expr.Compile and this wrapped error is returned, so the subscription cannot be loaded or added.","triggerScenarios":"Subscription with non-empty EventExpression failing expr.Compile(expr, expr.Env(types.NotificationEvent{})) in AddSubscription, ReplaceSubscription, loadSubscription, or compiledSub. This is the load-time path; error 120 is the same failure at update time.","commonSituations":"Stale expressions in notifications.yml written against an older NotificationEvent shape that has since changed; typos in event field names; broken syntax after manual edits.","solutions":["Check the wrapped expr error for the exact failing token","Align the expression with current fields on types.NotificationEvent (check for renames after upgrades)","Compile-test with the NotificationEvent env before persisting","Use the update path (UpdateSubscription) or edit the file and restart to replace a bad stored expression"],"exampleFix":"// before\ns.EventExpression = \"event.action == 'die' && event.actor\" // incomplete attribute\n// after\ns.EventExpression = \"event.Action == 'die'\"","handlingStrategy":"validation","validationCode":"func validEventExpr(s string) error {\n    _, err := expr.Compile(s, expr.Env(types.NotificationEvent{}))\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := sub.CompileExpressions(); err != nil {\n    return fmt.Errorf(\"cannot load subscription %d: %w\", sub.ID, err)\n}","preventionTips":["Re-verify stored expressions after upgrading (NotificationEvent fields may change)","Compile-check expressions with the NotificationEvent env before writing them to disk","Keep a CI test that loads and compiles the shipped notifications config"],"tags":["notifications","expr-lang","expression-compilation"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}