{"record":{"id":"f4607f878b0856f8","repo":"crowdsecurity/crowdsec","slug":"while-parsing-simulation-file-s-w","errorCode":null,"errorMessage":"while parsing simulation file '%s': %w","messagePattern":"while parsing simulation file '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csconfig/simulation.go","lineNumber":54,"sourceCode":"\tsimCfg := SimulationConfig{}\n\n\tif c.ConfigPaths.SimulationFilePath == \"\" {\n\t\tc.ConfigPaths.SimulationFilePath = filepath.Join(c.ConfigPaths.ConfigDir, \"simulation.yaml\")\n\t}\n\n\tpatcher := csyaml.NewPatcher(c.ConfigPaths.SimulationFilePath, \".local\")\n\n\trcfg, err := patcher.MergedPatchContent()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdec := yaml.NewDecoder(bytes.NewReader(rcfg))\n\tdec.KnownFields(true)\n\n\tif err := dec.Decode(&simCfg); err != nil {\n\t\tif !errors.Is(err, io.EOF) {\n\t\t\treturn fmt.Errorf(\"while parsing simulation file '%s': %w\", c.ConfigPaths.SimulationFilePath, err)\n\t\t}\n\t}\n\n\tif c.Crowdsec != nil {\n\t\tc.Crowdsec.SimulationConfig = simCfg\n\t}\n\n\tif c.Cscli != nil {\n\t\tc.Cscli.SimulationConfig = simCfg\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":36,"sourceCodeEnd":68,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/simulation.go#L36-L68","documentation":"LoadSimulation parses simulation.yaml with a strict decoder (KnownFields(true)) into simCfg. Any decode error other than EOF (empty file) is wrapped with the simulation file path. Strict mode means unknown keys also fail, catching outdated or misspelled config fields early at startup.","triggerScenarios":"simulation.yaml contains invalid YAML syntax, or unknown/renamed fields (KnownFields is enabled), e.g. an old 'simulation: true' boolean form left over from legacy configs where the current schema expects an exclusion list.","commonSituations":"Upgrading crowdsec with a stale simulation.yaml written for an older schema; hand edits adding typos like 'exlusions:'; a partially truncated file from a failed config sync.","solutions":["Run `yamllint /etc/crowdsec/simulation.yaml` and fix the reported syntax/line.","Remove unknown fields — strict decoding rejects them; valid content is a top-level 'exclusions' list.","If you still use the legacy boolean form ('simulation: true'), remove it — it is no longer part of the schema.","To start clean, replace the file with an empty 'exclusions: []' document, or delete it if simulation is unused."],"exampleFix":"// before (legacy simulation.yaml)\nsimulation: true\n// after\nexclusions:\n  - crowdsecurity/http-bf-wordpress","handlingStrategy":"validation","validationCode":"data, err := os.ReadFile(simPath)\nif err != nil { return err }\nvar v struct {\n    Exclusions []string `yaml:\"exclusions\"`\n}\ndec := yaml.NewDecoder(bytes.NewReader(data))\ndec.KnownFields(true)\nif err := dec.Decode(&v); err != nil && !errors.Is(err, io.EOF) {\n    return fmt.Errorf(\"simulation.yaml invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadSimulation(); err != nil {\n    if strings.Contains(err.Error(), \"while parsing simulation file\") {\n        // restore default simulation.yaml or drop unknown fields\n    }\n    return err\n}","preventionTips":["Keep simulation.yaml to the supported schema: a single 'exclusions' list.","Remove legacy boolean 'simulation:' style files on upgrade.","Run yamllint on the file after any manual edit."],"tags":["yaml","simulation","config"],"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"}