{"record":{"id":"195dfb6665224fae","repo":"amir20/dozzle","slug":"failed-to-compile-log-expression-w","errorCode":null,"errorMessage":"failed to compile log expression: %w","messagePattern":"failed to compile log expression: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notification/manager.go","lineNumber":203,"sourceCode":"\t\t\t\tif dispatcherID, ok := value.(int); ok {\n\t\t\t\t\tupdated.DispatcherID = dispatcherID\n\t\t\t\t}\n\t\t\tcase \"containerExpression\":\n\t\t\t\tif exprStr, ok := value.(string); ok {\n\t\t\t\t\tprogram, err := expr.Compile(exprStr, expr.Env(types.NotificationContainer{}))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tupdateErr = fmt.Errorf(\"failed to compile container expression: %w\", err)\n\t\t\t\t\t\treturn nil, xsync.CancelOp\n\t\t\t\t\t}\n\t\t\t\t\tupdated.ContainerExpression = exprStr\n\t\t\t\t\tupdated.ContainerProgram = program\n\t\t\t\t}\n\t\t\tcase \"logExpression\":\n\t\t\t\tif exprStr, ok := value.(string); ok {\n\t\t\t\t\tif exprStr != \"\" {\n\t\t\t\t\t\tprogram, err := expr.Compile(exprStr, expr.Env(types.NotificationLog{}))\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tupdateErr = fmt.Errorf(\"failed to compile log expression: %w\", err)\n\t\t\t\t\t\t\treturn nil, xsync.CancelOp\n\t\t\t\t\t\t}\n\t\t\t\t\t\tupdated.LogExpression = exprStr\n\t\t\t\t\t\tupdated.LogProgram = program\n\t\t\t\t\t} else {\n\t\t\t\t\t\tupdated.LogExpression = \"\"\n\t\t\t\t\t\tupdated.LogProgram = nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase \"metricExpression\":\n\t\t\t\tif exprStr, ok := value.(string); ok {\n\t\t\t\t\tif exprStr != \"\" {\n\t\t\t\t\t\tprogram, err := expr.Compile(exprStr, expr.Env(types.NotificationStat{}))\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tupdateErr = fmt.Errorf(\"failed to compile metric expression: %w\", err)\n\t\t\t\t\t\t\treturn nil, xsync.CancelOp\n\t\t\t\t\t\t}\n\t\t\t\t\t\tupdated.MetricExpression = exprStr","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/notification/manager.go#L185-L221","documentation":"For a non-empty \"logExpression\" update, Manager.UpdateSubscription compiles the string with expr against the types.NotificationLog environment. Failures (syntax errors, unknown fields/functions, type mismatches) are wrapped in this error and the update is cancelled, leaving the existing log expression intact.","triggerScenarios":"Updating a subscription with \"logExpression\" containing invalid expr syntax or fields not present on NotificationLog (e.g. referencing container-only fields, misspelled message/level keys), including empty-range or unbalanced constructs.","commonSituations":"Writing log matchers with the wrong field names or Go-side syntax, pasting regexes into expr context without proper quoting, or switching an expression written for container stats into the log context.","solutions":["Check the wrapped expr error for the failing token/position and fix the syntax.","Use only NotificationLog fields (message, level, etc.) in the expression.","An empty string is the supported way to clear the expression; don't pass placeholder text like \"none\".","Pre-validate the expression with expr.Compile(expr.Env(types.NotificationLog{})) in tests or the UI."],"exampleFix":"// before (unknown field)\n{\"logExpression\": \"msg contains 'timeout'\"}\n// after\n{\"logExpression\": \"message contains \\\"timeout\\\"\"}","handlingStrategy":"validation","validationCode":"if exprStr, ok := updates[\"logExpression\"].(string); ok && exprStr != \"\" {\n    if _, err := expr.Compile(exprStr, expr.Env(types.NotificationLog{})); err != nil {\n        return fmt.Errorf(\"invalid logExpression: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := manager.UpdateSubscription(id, updates); err != nil {\n    if strings.Contains(err.Error(), \"failed to compile log expression\") {\n        return fmt.Errorf(\"fix log expression against NotificationLog fields: %w\", err)\n    }\n    return err\n}","preventionTips":["Use only NotificationLog fields (message, level, etc.).","Use \"\" (empty string) to clear, never placeholder text.","Unit-test expressions with sample NotificationLog values."],"tags":["expression","validation","logs"],"backgroundTag":"expression-compilation-failed","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"}