{"record":{"id":"0f175d43f3ab7df3","repo":"crowdsecurity/crowdsec","slug":"error-decoding-parsing-configuration-file-s-v","errorCode":null,"errorMessage":"error decoding parsing configuration file '%s': %v","messagePattern":"error decoding parsing configuration file '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/parser/stage.go","lineNumber":107,"sourceCode":"\t// process the yaml\n\tdec := yaml.NewDecoder(yamlFile)\n\tdec.SetStrict(true)\n\n\tvar nodes []Node\n\n\tnodesCount := 0\n\n\tfor {\n\t\tnode := Node{}\n\t\tnode.OnSuccess = \"continue\" // default behavior is to continue\n\n\t\tif err = dec.Decode(&node); err != nil {\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\tlog.Tracef(\"End of yaml file\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\treturn nil, fmt.Errorf(\"error decoding parsing configuration file '%s': %v\", stageFile.Filename, err)\n\t\t}\n\n\t\t// check for empty bucket\n\t\tif node.Name == \"\" && node.Description == \"\" && node.Author == \"\" {\n\t\t\tlog.Infof(\"Node in %s has no name, author or description. Skipping.\", stageFile.Filename)\n\t\t\tcontinue\n\t\t}\n\n\t\t// check compat\n\t\tif node.FormatVersion == \"\" {\n\t\t\tlog.Tracef(\"no version in %s, assuming '1.0'\", node.Name)\n\t\t\tnode.FormatVersion = \"1.0\"\n\t\t}\n\n\t\tok, err := constraint.Satisfies(node.FormatVersion, constraint.Parser)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to check version : %s\", err)\n\t\t}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/parser/stage.go#L89-L125","documentation":"Wraps a YAML decoding error while parsing a parser stage file in processStageFile. The file opened fine, but the strict-mode YAML decoder rejected its content (syntax error, unknown field, duplicate key, bad type). CrowdSec refuses to load a node it cannot decode rather than silently skipping it.","triggerScenarios":"Calling processStageFile (via LoadStages) when dec.Decode(&node) returns a non-EOF error: malformed YAML syntax, tabs for indentation, unknown keys (strict decoding is enabled), wrong types for node fields.","commonSituations":"Hand-edited parser files with tab indentation or missing spaces, copy-pasted YAML with smart quotes, parser format updates adding fields that clash with local overrides, concatenated YAML documents with a stray '---'.","solutions":["Read the wrapped %v — yaml errors include the line/column of the problem","Validate the YAML with a linter (`yamllint`) fixing tabs, indentation, and quoting","Remove unknown top-level keys not in the Node schema (strict mode rejects them)","Compare against the hub's upstream version of the file: `cscli hub upgrade`"],"exampleFix":"# before (tab indentation → yaml error)\nfilter:\t'evt.Parsed.foo == \"bar\"'\n# after (spaces)\nfilter: 'evt.Parsed.foo == \"bar\"'","handlingStrategy":"validation","validationCode":"// strict-decode the file before installing it\nf, _ := os.Open(path)\ndec := yaml.NewDecoder(f)\ndec.SetStrict(true)\nvar n parser.Node\nif err := dec.Decode(&n); err != nil && !errors.Is(err, io.EOF) {\n    return fmt.Errorf(\"invalid parser yaml %s: %w\", path, err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := processStageFile(sf, pctx, ectx); err != nil {\n    log.Errorf(\"yaml invalid: %v\", err) // err message contains line/col\n}","preventionTips":["Run yamllint on custom parser files; never use tabs","Keep only known Node fields in the YAML (strict decoding)","Diff local overrides against the hub version after upgrades"],"tags":["yaml","parser","config","decoding"],"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"}