{"record":{"id":"969ba27d8f6adadd","repo":"crowdsecurity/crowdsec","slug":"unsupported-mode-s-for-file-source","errorCode":null,"errorMessage":"unsupported mode %s for file source","messagePattern":"unsupported mode (.+?) for file source","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/file/config.go","lineNumber":60,"sourceCode":"\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\n\tif s.config.Mode != configuration.CAT_MODE && s.config.Mode != configuration.TAIL_MODE {\n\t\treturn fmt.Errorf(\"unsupported mode %s for file source\", s.config.Mode)\n\t}\n\n\tfor _, exclude := range s.config.ExcludeRegexps {\n\t\tre, err := regexp.Compile(exclude)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not compile regexp %s: %w\", exclude, err)\n\t\t}\n\n\t\ts.exclude_regexps = append(s.exclude_regexps, re)\n\t}\n\n\treturn nil\n}\n\nfunc (s *Source) Configure(_ context.Context, yamlConfig []byte, logger *log.Entry, metricsLevel metrics.AcquisitionMetricsLevel) error {\n\ts.logger = logger\n\ts.metricsLevel = metricsLevel\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/file/config.go#L42-L78","documentation":"After parsing, UnmarshalConfig validates config.Mode: only \"cat\" and \"tail\" are supported (empty defaults to tail). Any other value returns \"unsupported mode %s for file source\". It is an enum-validation error on the file datasource's mode key.","triggerScenarios":"Setting `mode: read`, `mode: follow`, or any value other than cat/tail in a file acquisition block (ConfigureByDSN hard-codes cat; this error only comes from the YAML config path).","commonSituations":"Users porting configs from other log shippers (e.g. `mode: read` from filebeat habits); copy-pasting journalctl/docker datasource fields into a file source; typos like `mode: Tail` case variants that don't equal the constants.","solutions":["Set mode to exactly `tail` or `cat` (or omit it to get the tail default).","If you wanted one-pass reading of existing content, use mode: cat; for live following, use mode: tail.","Check casing — the comparison is against the exact constants, so use lowercase."],"exampleFix":"// before\nsource: file\nmode: read\nfilename: /var/log/syslog\n// after\nsource: file\nmode: cat\nfilename: /var/log/syslog","handlingStrategy":"validation","validationCode":"// Go: pre-validate mode against the allowed set\nmode := cfg.Mode\nif mode == \"\" {\n\tmode = \"tail\"\n}\nif mode != \"cat\" && mode != \"tail\" {\n\treturn fmt.Errorf(\"mode must be 'cat' or 'tail', got %q\", mode)\n}","typeGuard":null,"tryCatchPattern":"if err := src.UnmarshalConfig(cfgYAML); err != nil {\n\tif strings.Contains(err.Error(), \"unsupported mode\") {\n\t\t// fix mode in the YAML block, then retry parse\n\t}\n}","preventionTips":["Omit `mode` entirely unless you specifically need `cat`.","Remember the only two values: `cat` (read from start, stop at EOF) and `tail` (follow).","Keep values lowercase; the comparison is exact.","Lint acquis.yaml against the datasource schema in CI."],"tags":["config","file-source","enum"],"backgroundTag":"invalid-enum-value","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"}