crowdsecurity/crowdsec · error
invalid duration: %w
Error message
invalid duration: %w
What it means
Returned by ConfigureByDSN when the 'delay_for' query parameter of a loki:// DSN cannot be parsed as a Go duration string (e.g. '5x' or 'abc'). Wraps time.ParseDuration; the value must also be within 0–5s to pass the follow-up range check.
Source
Thrown at pkg/acquisition/modules/loki/config.go:159
}
if q := params.Get("query"); q != "" {
l.Config.Query = q
}
if w := params.Get("wait_for_ready"); w != "" {
l.Config.WaitForReady, err = time.ParseDuration(w)
if err != nil {
return err
}
} else {
l.Config.WaitForReady = 10 * time.Second
}
if d := params.Get("delay_for"); d != "" {
l.Config.DelayFor, err = time.ParseDuration(d)
if err != nil {
return fmt.Errorf("invalid duration: %w", err)
}
if l.Config.DelayFor < 0*time.Second || l.Config.DelayFor > 5*time.Second {
return errors.New("delay_for should be a value between 1s and 5s")
}
} else {
l.Config.DelayFor = 0 * time.Second
}
if s := params.Get("since"); s != "" {
l.Config.Since, err = time.ParseDuration(s)
if err != nil {
return fmt.Errorf("invalid since in dsn: %w", err)
}
}
if maxFailureDuration := params.Get("max_failure_duration"); maxFailureDuration != "" {
duration, err := time.ParseDuration(maxFailureDuration)View on GitHub (pinned to 909b515798)
Solutions
- Use a duration with unit, e.g. delay_for=1s, delay_for=500ms
- Values must be between 0 and 5 seconds
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/acquisition/modules/loki/config.go:159 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/3871d5ffec19e210.
Report an issue: GitHub.