{"record":{"id":"32ff02e33f422dd5","repo":"crowdsecurity/crowdsec","slug":"cannot-parse-fileacquisition-configuration-s","errorCode":null,"errorMessage":"cannot parse FileAcquisition configuration: %s","messagePattern":"cannot parse FileAcquisition configuration: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/file/config.go","lineNumber":40,"sourceCode":"\ntype Configuration struct {\n\tFilenames                         []string\n\tExcludeRegexps                    []string `yaml:\"exclude_regexps\"`\n\tFilename                          string\n\tForceInotify                      bool          `yaml:\"force_inotify\"`\n\tMaxBufferSize                     int           `yaml:\"max_buffer_size\"`\n\tPollWithoutInotify                *bool         `yaml:\"poll_without_inotify\"`\n\tDiscoveryPollEnable               bool          `yaml:\"discovery_poll_enable\"`\n\tDiscoveryPollInterval             time.Duration `yaml:\"discovery_poll_interval\"`\n\tconfiguration.DataSourceCommonCfg `yaml:\",inline\"`\n}\n\nfunc (s *Source) UnmarshalConfig(yamlConfig []byte) error {\n\ts.config = Configuration{}\n\n\terr := yaml.UnmarshalWithOptions(yamlConfig, &s.config, yaml.Strict())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot parse FileAcquisition configuration: %s\", yaml.FormatError(err, false, false))\n\t}\n\n\tif s.logger != nil {\n\t\ts.logger.Tracef(\"FileAcquisition configuration: %+v\", s.config)\n\t}\n\n\tif s.config.Filename != \"\" {\n\t\ts.config.Filenames = append(s.config.Filenames, s.config.Filename)\n\t}\n\n\tif len(s.config.Filenames) == 0 {\n\t\treturn errors.New(\"no filename or filenames configuration provided\")\n\t}\n\n\tif s.config.Mode == \"\" {\n\t\ts.config.Mode = configuration.TAIL_MODE\n\t}\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/file/config.go#L22-L58","documentation":"UnmarshalConfig for the file datasource parses the acquisition YAML with goccy/go-yaml in Strict() mode, so unknown keys or type mismatches produce a parse error, wrapped as \"cannot parse FileAcquisition configuration\". It fires on any malformed or schema-invalid file-source configuration block, before any file is opened.","triggerScenarios":"Any YAML unmarshal failure into the file Configuration struct: a misspelled key (strict mode rejects unknown fields), wrong value type (e.g. max_buffer_size: \"abc\"), bad indentation, or tabs in YAML.","commonSituations":"Copy-pasted config with wrong indentation; using keys from another datasource (e.g. docker's container_name) in a file source; durations given as bare numbers; stray tab characters in acquis.yaml.","solutions":["Read the formatted error: it names the offending key/line — fix that key's spelling or value type.","Only use file-source keys: filenames/filename, mode, exclude_regexps, force_inotify, max_buffer_size, poll_without_inotify, discovery_poll_enable, discovery_poll_interval, plus labels/log_level/etc.","Validate YAML syntax (tabs are illegal in YAML — use spaces).","Test with `cscli` or crowdsec startup in dry-run to confirm the block parses before deploying."],"exampleFix":"// before\nsource: file\nfilename: /var/log/auth.log\ncontainer_name: foo   # unknown key -> strict YAML error\n// after\nsource: file\nfilename: /var/log/auth.log","handlingStrategy":"validation","validationCode":"// Go: strict-parse the config before handing it to the source\nvar probe fileacquisition.Configuration\nif err := yaml.UnmarshalWithOptions(cfgYAML, &probe, yaml.Strict()); err != nil {\n\treturn fmt.Errorf(\"invalid file acquisition YAML: %s\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := src.UnmarshalConfig(cfgYAML); err != nil {\n\t// the wrapped message names the offending key/line; log and abort startup\n\tlog.Fatalf(\"file source config invalid: %v\", err)\n}","preventionTips":["Use spaces, never tabs, in acquis.yaml.","Only use documented file-source keys; unknown keys fail under strict YAML.","Validate config in CI with a strict unmarshal before deployment.","Copy config examples from the official docs, not other datasources."],"tags":["yaml","config","file-source"],"backgroundTag":"schema-validation-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}