crowdsecurity/crowdsec · error
invalid limit in dsn: %w
Error message
invalid limit in dsn: %w
What it means
ConfigureByDSN parses the Loki acquisition DSN's query parameters. The 'limit' parameter must be a valid integer; if strconv.Atoi fails, this error wraps the parse failure and aborts configuration. It exists to fail fast on a malformed DSN rather than silently defaulting.
Source
Thrown at pkg/acquisition/modules/loki/config.go:190
return fmt.Errorf("invalid since in dsn: %w", err)
}
}
if maxFailureDuration := params.Get("max_failure_duration"); maxFailureDuration != "" {
duration, err := time.ParseDuration(maxFailureDuration)
if err != nil {
return fmt.Errorf("invalid max_failure_duration in dsn: %w", err)
}
l.Config.MaxFailureDuration = duration
} else {
l.Config.MaxFailureDuration = 5 * time.Second // for OneShot mode it doesn't make sense to have longer duration
}
if limit := params.Get("limit"); limit != "" {
limit, err := strconv.Atoi(limit)
if err != nil {
return fmt.Errorf("invalid limit in dsn: %w", err)
}
l.Config.Limit = limit
} else {
l.Config.Limit = 5000 // max limit allowed by loki
}
if logLevel := params.Get("log_level"); logLevel != "" {
level, err := log.ParseLevel(logLevel)
if err != nil {
return fmt.Errorf("invalid log_level in dsn: %w", err)
}
l.Config.LogLevel = level
l.logger.Logger.SetLevel(level)
}
if noReadyCheck := params.Get("no_ready_check"); noReadyCheck != "" {View on GitHub (pinned to 909b515798)
Solutions
- Set 'limit' to a plain integer in the DSN, e.g. loki://host:3100/?limit=5000
- Remove the 'limit' parameter entirely to use the default of 5000 (Loki's max)
- URL-encode the parameter if special characters are intended
Example fix
// before loki://localhost:3100/?limit=10,000 // after loki://localhost:3100/?limit=10000
Defensive patterns
Strategy: validation
Validate before calling
limitRaw := params.Get("limit")
if limitRaw != "" {
n, err := strconv.Atoi(limitRaw)
if err != nil || n <= 0 {
return fmt.Errorf("limit must be a positive integer, got %q", limitRaw)
}
} Prevention
- Keep numeric DSN params unit-free and unquoted
- Validate the whole DSN with cscli before deploying acquis.yaml
When it happens
Trigger: A DSN such as loki://host:3100/?limit=abc or limit=1_000 is passed to the Loki acquire configuration.
Common situations: Typos or pasted URLs where 'limit' contains units, commas, or quotes; template variables left unexpanded in acquis.yaml.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- loki query is mandatory
- delay_for should be a value between 1s and 5s
- empty loki host
- invalid log_level in dsn: %w
- invalid no_ready_check in dsn: %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/4acdec9081d27cfc.
Report an issue: GitHub.