{"record":{"id":"85c2775d2e5cc24f","repo":"crowdsecurity/crowdsec","slug":"failed-to-load-parser-config-w","errorCode":null,"errorMessage":"failed to load parser config: %w","messagePattern":"failed to load parser config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/parser/unix_parser.go","lineNumber":145,"sourceCode":"\t/*\n\t\tLoad enrichers\n\t*/\n\tlog.Info(\"Loading enrich plugins\")\n\n\tparsers.EnricherCtx, err = Loadplugin()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load enrich plugin: %w\", err)\n\t}\n\n\t/*\n\t Load the actual parsers\n\t*/\n\n\tlog.Infof(\"Loading parsers from %d files\", len(parsers.StageFiles))\n\n\tparsers.Nodes, err = LoadStages(parsers.StageFiles, parsers.Ctx, parsers.EnricherCtx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load parser config: %w\", err)\n\t}\n\n\tif len(parsers.PovfwStageFiles) > 0 {\n\t\tlog.Info(\"Loading postoverflow parsers\")\n\n\t\tparsers.Povfwnodes, err = LoadStages(parsers.PovfwStageFiles, parsers.PovfwCtx, parsers.EnricherCtx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load postoverflow config: %w\", err)\n\t\t}\n\t} else {\n\t\tlog.Info(\"No postoverflow parsers to load\")\n\n\t\tparsers.Povfwnodes = []Node{}\n\t}\n\n\tif cConfig.Prometheus != nil && cConfig.Prometheus.Enabled {\n\t\tparsers.Ctx.Profiling = true\n\t\tparsers.PovfwCtx.Profiling = true","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/parser/unix_parser.go#L127-L163","documentation":"LoadStages parses the YAML parser configuration files (StageFiles) and compiles them into the parser node tree; LoadParsers wraps failures in \"failed to load parser config\". This means at least one parser YAML file is invalid — bad syntax, unknown fields, or a node that fails to compile (bad expression, missing stage). The wrapped error points at the offending file/node.","triggerScenarios":"LoadStages(parsers.StageFiles, ...) returning an error during LoadParsers — a .yaml file in config/parsers/s*/ is unparseable YAML, references an unknown format, or has a bad filter expression.","commonSituations":"Hand-edited parser file with wrong indentation; custom parser installed from the hub that conflicts or has a typo; leftover partially-written file after a failed `cscli hub upgrade`; a parser targeting a newer crowdsec format version.","solutions":["Read the wrapped error for the exact file/line, then fix or remove that parser YAML under /etc/crowdsec/parsers/","Validate YAML syntax with `yamllint` or `cscli` before restarting","Run `cscli hub upgrade` to restore pristine hub parsers, and move custom parsers aside to bisect","Check `cscli parsers list -a` for broken/incompatible parser collections"],"exampleFix":"// before (custom parser file)\nfilter: 'evt.Parsed.program == 'sshd''   # nested quotes\n// after\nfilter: evt.Parsed.program == 'sshd'","handlingStrategy":"try-catch","validationCode":"import \"gopkg.in/yaml.v3\"\nfunc validYAML(path string) error {\n  b, err := os.ReadFile(path); if err != nil { return err }\n  var m map[string]any\n  return yaml.Unmarshal(b, &m)\n}","typeGuard":null,"tryCatchPattern":"parsers, err := parser.LoadParsers(cfg)\nif err != nil {\n  if strings.Contains(err.Error(), \"failed to load parser config\") {\n    log.Fatalf(\"invalid parser yaml, fix file named in: %v\", err)\n  }\n  return err\n}","preventionTips":["Run `yamllint` on custom parser files before deploying","Validate parsers with `cscli explain` against a sample log","Keep custom parsers in version control and lint in CI"],"tags":["crowdsec","parser","yaml","config","startup"],"backgroundTag":"yaml-parse-error","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}