amir20/dozzle · error
failed to compile event expression
Error message
failed to compile event expression: %w
What it means
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.
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
Example fix
// before s.EventExpression = "event.action == 'die' && event.actor" // incomplete attribute // after s.EventExpression = "event.Action == 'die'"
Defensive patterns
Strategy: validation
Validate before calling
func validEventExpr(s string) error {
_, err := expr.Compile(s, expr.Env(types.NotificationEvent{}))
return err
} Try / catch
if err := sub.CompileExpressions(); err != nil {
return fmt.Errorf("cannot load subscription %d: %w", sub.ID, err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to compile event expression
- failed to compile container expression
- failed to compile log expression
- failed to compile metric expression
- (await res.json().catch(() =>
AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07).
Data as JSON: /api/errors/697d90a9aa3ef0e0.
Report an issue: GitHub.
Appendix: source
Thrown at internal/notification/types.go:199
program, err := expr.Compile(s.LogExpression, expr.Env(types.NotificationLog{}))
if err != nil {
return fmt.Errorf("failed to compile log expression: %w", err)
}
s.LogProgram = program
}
if s.MetricExpression != "" {
program, err := expr.Compile(s.MetricExpression, expr.Env(types.NotificationStat{}))
if err != nil {
return fmt.Errorf("failed to compile metric expression: %w", err)
}
s.MetricProgram = program
}
if s.EventExpression != "" {
program, err := expr.Compile(s.EventExpression, expr.Env(types.NotificationEvent{}))
if err != nil {
return fmt.Errorf("failed to compile event expression: %w", err)
}
s.EventProgram = program
}
return nil
}
// DispatcherConfig represents a dispatcher configuration
type DispatcherConfig struct {
ID int `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"` // "webhook" or "cloud"
URL string `json:"url,omitempty" yaml:"url,omitempty"`
Template string `json:"template,omitempty" yaml:"template,omitempty"` // Go template for custom payload format
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"` // Custom HTTP headers
Prefix string `json:"prefix,omitempty" yaml:"-"` // Cloud dispatcher API key prefix (not persisted)
}
View on GitHub (pinned to d9463cbe21)