{"record":{"id":"cb3e3f294710713c","repo":"crowdsecurity/crowdsec","slug":"could-not-stat-file-s-w","errorCode":null,"errorMessage":"could not stat file %s : %w","messagePattern":"could not stat file (.+?) : %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/file/run.go","lineNumber":37,"sourceCode":"\t\"gopkg.in/tomb.v2\"\n\n\t\"github.com/crowdsecurity/go-cs-lib/trace\"\n\n\t\"github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration\"\n\t\"github.com/crowdsecurity/crowdsec/pkg/fsutil\"\n\t\"github.com/crowdsecurity/crowdsec/pkg/metrics\"\n\t\"github.com/crowdsecurity/crowdsec/pkg/pipeline\"\n)\n\nconst defaultPollInterval = 30 * time.Second\n\nfunc (s *Source) OneShot(ctx context.Context, out chan pipeline.Event) error {\n\ts.logger.Debug(\"In oneshot\")\n\n\tfor _, file := range s.files {\n\t\tfi, err := os.Stat(file)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not stat file %s : %w\", file, err)\n\t\t}\n\n\t\tif fi.IsDir() {\n\t\t\ts.logger.Warnf(\"%s is a directory, ignoring it.\", file)\n\t\t\tcontinue\n\t\t}\n\n\t\ts.logger.Infof(\"reading %s at once\", file)\n\n\t\terr = s.readFile(ctx, file, out)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/file/run.go#L19-L55","documentation":"OneShot of the file source calls os.Stat on each file to read before tailing; the file does not exist or is not statable (permissions, broken symlink), so one-shot read mode cannot proceed and returns the wrapped error.","triggerScenarios":"Thrown at pkg/acquisition/modules/file/run.go:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the file exists and the path is correct","Fix read permissions so the crowdsec user can access the file","Remove stale entries from the acquisition configuration"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}