crowdsecurity/crowdsec · error
invalid VictoriaLogs URL %q: %w
Error message
invalid VictoriaLogs URL %q: %w
What it means
updateURI rewrites the stored query URI to shift the start time for the next VictoriaLogs query range request. It first calls url.Parse on the configured URI; if the URI is malformed the parse error is wrapped with "invalid VictoriaLogs URL". Normally the URI was already validated at configuration time, so hitting this indicates a corrupted or hand-edited URI.
Source
Thrown at pkg/acquisition/modules/victorialogs/internal/vlclient/vl_client.go:55
URL string
Prefix string
Query string
Headers map[string]string
Username string
Password string
Since time.Duration
FailMaxDuration time.Duration
Limit int
}
func updateURI(uri string, newStart time.Time) (string, error) {
u, err := url.Parse(uri)
if err != nil {
return "", fmt.Errorf("invalid VictoriaLogs URL %q: %w", uri, err)
}
queryParams := u.Query()
if !newStart.IsZero() {
// +1 the last timestamp to avoid getting the same result again.
updatedStart := newStart.Add(1 * time.Nanosecond)
queryParams.Set("start", updatedStart.Format(time.RFC3339Nano))
}
u.RawQuery = queryParams.Encode()
return u.String(), nil
}
func (lc *VLClient) SetTomb(t *tomb.Tomb) {
lc.t = t
}View on GitHub (pinned to 909b515798)
Solutions
- Fix the URL in the DSN/acquis.yaml so it is a valid absolute URL (scheme://host[:port][/path])
- Percent-encode spaces and special characters (e.g. %20) or remove them
- Validate the URL with a quick `url.Parse` snippet or any URL validator before deploying
- Re-run cscli/crowdsec config validation to catch it at load time
Example fix
// before url: victorialogs+http://127.0.0.1:8428/my path/ // after url: victorialogs+http://127.0.0.1:8428/my%20path/
Defensive patterns
Strategy: validation
Validate before calling
try { new URL(uri.replace(/^victorialogs\+/, "")) } catch (e) {
throw new Error(`invalid VictoriaLogs URL: ${uri}`)
} Try / catch
try {
await startAcquisition(cfg)
} catch (e) {
if (String(e).includes("invalid VictoriaLogs URL")) {
log.error("Fix the URL in acquis.yaml:", e.message)
}
} Prevention
- Percent-encode spaces and special characters in URLs
- Keep the URL on one line in acquis.yaml — no wrapped whitespace
- Test the URL with curl before adding it to config
When it happens
Trigger: doQueryRange calls updateURI with a URI that url.Parse rejects — e.g. a DSN base URL with invalid characters (unescaped spaces, stray control characters) or a malformed scheme/colon placement.
Common situations: Misconfigured URL in acquis.yaml containing spaces or invalid characters, proxy URLs pasted with surrounding whitespace, or unusual characters that need percent-encoding.
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
- invalid Loki URL %q: %w
- while parsing dsn '%s': %w
- invalid DSN %s for VictoriaLogs source, must start with vict
- failed to parse DSN parameters: %w
- query is mandatory (at least start_date and end_date or back
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/d709e8335cd1266a.
Report an issue: GitHub.