crowdsecurity/crowdsec · warning · InvalidFilter
invalid offset value: %w: %w
Error message
invalid offset value: %w: %w
What it means
applyDecisionFilter rejects the request because the 'offset' query parameter is not a valid integer (strconv.Atoi fails). Wrapped with the InvalidFilter sentinel for programmatic identification by LAPI clients.
Source
Thrown at pkg/database/decisionfilter.go:92
predicates...,
),
))
case "ip", "range":
rng, err = csnet.NewRange(value[0])
if err != nil {
return nil, fmt.Errorf("unable to convert '%s' to int: %w: %w", value[0], err, InvalidIPOrRange)
}
case "limit":
limit, err := strconv.Atoi(value[0])
if err != nil {
return nil, fmt.Errorf("invalid limit value: %w: %w", err, InvalidFilter)
}
query = query.Limit(limit)
case "offset":
offset, err := strconv.Atoi(value[0])
if err != nil {
return nil, fmt.Errorf("invalid offset value: %w: %w", err, InvalidFilter)
}
query = query.Offset(offset)
case "id_gt":
id, err := strconv.Atoi(value[0])
if err != nil {
return nil, fmt.Errorf("invalid id_gt value: %w: %w", err, InvalidFilter)
}
query = query.Where(decision.IDGT(id))
}
}
query, err = decisionIPFilter(query, contains, rng)
if err != nil {
return nil, fmt.Errorf("fail to apply StartIpEndIpFilter: %w", err)
}
View on GitHub (pinned to 909b515798)
Solutions
- Send a plain non-negative integer for offset (e.g. ?offset=50).
- Omit offset when not paginating.
- Validate/sanitize the numeric parameter client-side before the request.
- Log the full query string when building pagination loops to spot empty values.
Example fix
// before GET /v1/decisions?offset= // after GET /v1/decisions?offset=50
Defensive patterns
Strategy: validation
Validate before calling
offset, err := strconv.Atoi(offsetRaw)
if err != nil || offset < 0 {
offset = 0
}
// then use offset in the request Try / catch
resp, err := lapi.GetDecisions(ctx, models.GetDecisionsOpts{Offset: &offset})
if err != nil && strings.Contains(err.Error(), "invalid offset value") {
return fmt.Errorf("offset must be an integer, got %q", offsetRaw)
} Prevention
- Reset pagination counters on errors so they never go NaN/empty
- Clamp offset to >= 0 client-side
- Use url.Values for query construction
- Log full request URLs when paginating
When it happens
Trigger: GET /v1/decisions?offset=ten or an empty ?offset= on decisions listing endpoints using QueryDecisionWithFilter.
Common situations: Pagination loops where a page counter became NaN/empty before URL construction; copy-pasted query strings with units ('offset=10items').
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- invalid limit value: %w: %w
- invalid id_gt value: %w: %w
- invalid contains value: %w: %w
- unable to convert '%s' to int: %w: %w
- bad limit in parameters: %s: %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/230ad2619d81c742.
Report an issue: GitHub.