crowdsecurity/crowdsec · error
while parsing dsn '%s': %w
Error message
while parsing dsn '%s': %w
What it means
ConfigureByDSN failed when url.Parse could not interpret the DSN string. The DSN passed via -type victorialogs acquisition (e.g. on cscli or acquis DSN) is not a parseable URL, so the source cannot derive its configuration.
Source
Thrown at pkg/acquisition/modules/victorialogs/config.go:126
FailMaxDuration: s.Config.MaxFailureDuration,
}
s.Client = vlclient.NewVLClient(clientConfig)
s.Client.Logger = logger.WithFields(log.Fields{"component": "victorialogs-client", "source": s.Config.URL})
return nil
}
func (s *Source) ConfigureByDSN(_ context.Context, dsn string, labels map[string]string, logger *log.Entry, uuid string) error {
s.logger = logger
s.Config = Configuration{}
s.Config.Mode = configuration.CAT_MODE
s.Config.Labels = labels
s.Config.UniqueId = uuid
u, err := url.Parse(dsn)
if err != nil {
return fmt.Errorf("while parsing dsn '%s': %w", dsn, err)
}
if u.Scheme != "victorialogs" {
return fmt.Errorf("invalid DSN %s for VictoriaLogs source, must start with victorialogs://", dsn)
}
if u.Host == "" {
return errors.New("empty host")
}
scheme := "http"
params := u.Query()
if q := params.Get("ssl"); q != "" {
scheme = "https"
}
View on GitHub (pinned to 909b515798)
Solutions
- Inspect the wrapped url.Parse error to find the offending character and escape or remove it (e.g. use %20 for spaces).
- Rewrite the DSN in the standard form victorialogs://host:port with proper URL escaping.
- Quote the DSN in YAML and check for stray whitespace or line breaks introduced by copy-paste.
Example fix
// before victorialogs://vl host:9428 # space breaks url.Parse // after victorialogs://vl-host:9428
Defensive patterns
Strategy: validation
Validate before calling
if _, err := url.Parse(dsn); err != nil {
return fmt.Errorf("malformed DSN %q: %w", dsn, err)
} Try / catch
u, err := url.Parse(dsn)
if err != nil {
log.Errorf("bad DSN %q: %v", dsn, err)
return err
} Prevention
- URL-escape special characters when composing DSNs.
- Trim whitespace/newlines from DSN strings sourced from shell or docs.
- Quote DSNs in YAML files.
When it happens
Trigger: A DSN string like 'victorialogs://host:port' contains characters illegal in a URL (unescaped spaces, stray '%', control chars) making url.Parse return an error.
Common situations: Pasting a DSN with a trailing space or newline from a shell/docs; unescaped special characters in a password or query embedded in the DSN; quoting mistakes in acquis.yaml leaving raw '%' sequences.
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 DSN %s for VictoriaLogs source, must start with vict
- empty loki host
- failed to parse DSN %s: %w
- query is mandatory (at least start_date and end_date or back
- cloudwatch path must contain group and stream : /my/group/na
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/9aeeb2139c12eeff.
Report an issue: GitHub.