crowdsecurity/crowdsec · error
querying range: %w
Error message
querying range: %w
What it means
After each successful poll, queryRange calls updateURI to compute the next pagination URI from the received timestamps. A failure there (url.Parse failure on the stored URI) is wrapped as 'querying range' and terminates the datasource.
Source
Thrown at pkg/acquisition/modules/loki/internal/lokiclient/loki_client.go:189
close(c)
return nil
}
if len(lq.Data.Result) > 0 {
lc.Logger.Debugf("(timer:%v) %d results / %d entries result[0] (uri:%s)", lc.currentTickerInterval, len(lq.Data.Result), len(lq.Data.Result[0].Entries), uri)
} else {
lc.Logger.Debugf("(timer:%v) no results (uri:%s)", lc.currentTickerInterval, uri)
}
if infinite {
if len(lq.Data.Result) > 0 { //as long as we get results, we keep lowest ticker
lc.decreaseTicker(ticker)
} else {
lc.increaseTicker(ticker)
}
}
uri, err = updateURI(uri, lq, infinite)
if err != nil {
return fmt.Errorf("querying range: %w", err)
}
}
}
}
func (lc *LokiClient) getURLFor(endpoint string, params map[string]string) string {
u, err := url.Parse(lc.config.LokiURL)
if err != nil {
return ""
}
queryParams := u.Query()
for k, v := range params {
queryParams.Set(k, v)
}
u.RawQuery = queryParams.Encode()
u.Path, err = url.JoinPath(lc.config.LokiPrefix, u.Path, endpoint)
if err != nil {View on GitHub (pinned to 909b515798)
Solutions
- Fix the DSN URL so it parses as a valid URL
- Percent-encode special characters in query parameters
- Test the exact URL with curl before putting it in acquis.yaml
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := url.Parse(dsnURL); err != nil {
return fmt.Errorf("fix DSN URL before starting datasource: %w", err)
} Try / catch
if _, err := updateURI(uri, lq, infinite); err != nil {
log.Errorf("pagination broke after %s: %v", uri, err)
// restart the polling loop from the base URL instead of exiting
} Prevention
- Keep the base URL simple and fully encoded
- Re-test DSN URLs after any proxy or ingress change
When it happens
Trigger: updateURI returns invalid Loki URL (error 464) during pagination — malformed base URI in config propagates through the polling loop.
Common situations: Same root causes as invalid Loki URL: badly formed DSN URL, unencoded special characters.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- empty loki host
- invalid Loki URL %q: %w
- query is mandatory (at least start_date and end_date or back
- cloudwatch path must contain group and stream : /my/group/na
- loki query is mandatory
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/71b22fa8b1f85955.
Report an issue: GitHub.