crowdsecurity/crowdsec · error
failed to parse: %w
Error message
failed to parse: %w
What it means
ParseSourceConfig failed to unmarshal the common datasource configuration (DataSourceCommonCfg) out of the YAML document. The goccy/go-yaml unmarshalling error is reformatted with yaml.FormatError (non-strict, no source hints) and wrapped as 'failed to parse: %w'. It fires when the document's common fields (source, labels, mode, etc.) have YAML syntax errors or type mismatches — note unmarshalling is intentionally non-strict because datasource-specific keys are collected later.
Source
Thrown at pkg/acquisition/acquisition.go:248
if err != nil {
return nil, err
}
// if there are not keys or only comments, the document will be skipped
empty, err := csyaml.IsEmptyYAML(bytes.NewReader(yamlDoc))
if err != nil {
return nil, err
}
if empty {
return nil, ErrEmptyYAMLDocument
}
var sub configuration.DataSourceCommonCfg
// can't be strict here, the doc contains specific datasource config too but we won't collect them now.
if err = yaml.UnmarshalWithOptions(yamlDoc, &sub); err != nil {
return nil, fmt.Errorf("failed to parse: %w", errors.New(yaml.FormatError(err, false, false)))
}
parsed := &ParsedSourceConfig{}
// report that the user did not specify a source
if sub.Source == "" {
parsed.SourceMissing = true
}
// report that the user specified a source that doesn't match with one detected from the presence of other fields
if detectedType != "" {
if sub.Source != "" && sub.Source != detectedType {
parsed.SourceOverridden = sub.Source
}
sub.Source = detectedType
}
View on GitHub (pinned to 909b515798)
Solutions
- Validate the datasource stanza with a YAML linter; the wrapped error names the line and problem
- Check for tabs instead of spaces, unquoted special characters, or wrong indentation under the datasource block
- Ensure scalar fields like mode and source are plain strings, and labels is a mapping of string to string
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/acquisition/acquisition.go:248 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/464da24e10f85b15.
Report an issue: GitHub.