crowdsecurity/crowdsec · error

invalid limit in dsn: %w

Error message

invalid limit in dsn: %w

What it means

ConfigureByDSN parses the optional `limit` DSN parameter with strconv.Atoi, which requires a plain integer. Any non-numeric value causes the error to be wrapped with "invalid limit in dsn" and configuration to fail.

Source

Thrown at pkg/acquisition/modules/victorialogs/config.go:179

			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)
		}

		s.Config.MaxFailureDuration = duration
	} else {
		s.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)
		}

		s.Config.Limit = limit
	}

	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)
		}

		s.Config.LogLevel = level
		s.logger.Logger.SetLevel(level)
	}

	s.Config.URL = fmt.Sprintf("%s://%s", scheme, u.Host)
	if u.User != nil {
		s.Config.Auth.Username = u.User.Username()

View on GitHub (pinned to 909b515798)

Solutions

  1. Set `limit` to a plain decimal integer, e.g. `limit=10000`
  2. Remove spaces, separators and unit suffixes (no commas, underscores or "k")
  3. Omit the parameter to use the default limit
  4. Check the wrapped strconv error for the offending input

Example fix

// before
url: victorialogs+http://127.0.0.1:8428?limit=10,000
// after
url: victorialogs+http://127.0.0.1:8428?limit=10000
Defensive patterns

Strategy: validation

Validate before calling

const limit = p.searchParams.get("limit")
if (limit && !/^\d+$/.test(limit)) {
  throw new Error(`invalid limit: ${limit}`)
}

Prevention

When it happens

Trigger: Setting `limit=` in the DSN to a value Atoi cannot parse, e.g. `limit=1000 events`, `limit=1_000`, or an empty-but-present value is skipped, but `limit=0x10` fails.

Common situations: Copy-pasting formatted numbers with separators or suffixes ("10k"), or quoting/spacing mistakes in acquis.yaml; the limit caps the number of log entries fetched per query.

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


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/6d1b0d5ca3d81a3c. Report an issue: GitHub.