{"record":{"id":"8c7cbbfeefa4e608","repo":"amir20/dozzle","slug":"failed-to-compile-container-expression-w-8c7cbb","errorCode":null,"errorMessage":"failed to compile container expression: %w","messagePattern":"failed to compile container expression: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notification/types.go","lineNumber":175,"sourceCode":"\t}\n\treturn s.TriggeredContainerIDs.Size()\n}\n\n// AddTriggeredContainer adds a container ID to the triggered set\nfunc (s *Subscription) AddTriggeredContainer(id string) {\n\tif s.TriggeredContainerIDs == nil {\n\t\ts.TriggeredContainerIDs = xsync.NewMap[string, struct{}]()\n\t}\n\ts.TriggeredContainerIDs.Store(id, struct{}{})\n}\n\n// CompileExpressions compiles all expression strings into executable programs.\n// Returns an error describing which expression failed to compile.\nfunc (s *Subscription) CompileExpressions() error {\n\tif s.ContainerExpression != \"\" {\n\t\tprogram, err := expr.Compile(s.ContainerExpression, expr.Env(types.NotificationContainer{}))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to compile container expression: %w\", err)\n\t\t}\n\t\ts.ContainerProgram = program\n\t}\n\n\tif s.LogExpression != \"\" {\n\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","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/notification/types.go#L157-L193","documentation":"Subscription.CompileExpressions compiles ContainerExpression with expr against the types.NotificationContainer environment. An invalid expression (syntax error or unknown identifier) aborts compilation and returns a wrapped error naming which expression failed; the subscription is left unusable.","triggerScenarios":"AddSubscription, ReplaceSubscription, loadSubscription, or compiledSub receiving a Subscription whose ContainerExpression is non-empty and rejected by expr.Compile(expr, expr.Env(types.NotificationContainer{})).","commonSituations":"Hand-edited notifications.yml with a bad container expression; typos like container.name instead of the real field on NotificationContainer; expressions copied from a different subscription type (log/metric) using incompatible fields.","solutions":["Read the wrapped expr error for the exact parse position/unknown identifier","Use only fields defined on types.NotificationContainer in the expression","Compile-test the expression in a unit test or expr playground with the NotificationContainer env before persisting","If the field is intentional, add it to types.NotificationContainer so the env exposes it"],"exampleFix":"// before\ns.ContainerExpression = \"container.name == 'web'\" // unknown field\n// after\ns.ContainerExpression = \"container.Name == 'web'\" // field on types.NotificationContainer","handlingStrategy":"validation","validationCode":"func validContainerExpr(s string) error {\n    _, err := expr.Compile(s, expr.Env(types.NotificationContainer{}))\n    return err\n}","typeGuard":null,"tryCatchPattern":"sub := types.Subscription{ContainerExpression: expr}\nif err := sub.CompileExpressions(); err != nil {\n    return fmt.Errorf(\"rejecting subscription: %w\", err)\n}","preventionTips":["Compile-check expressions before persisting to notifications.yml","Reference only NotificationContainer fields; add fields to the type when needed","Add tests that load and compile the production notifications.yml"],"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"}