{"record":{"id":"9d06dccfa3a666ab","repo":"crowdsecurity/crowdsec","slug":"empty-file-dsn","errorCode":null,"errorMessage":"empty file:// DSN","messagePattern":"empty file:// DSN","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/file/config.go","lineNumber":164,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc (s *Source) ConfigureByDSN(_ context.Context, dsn string, labels map[string]string, logger *log.Entry, uuid string) error {\n\tif !strings.HasPrefix(dsn, \"file://\") {\n\t\treturn fmt.Errorf(\"invalid DSN %s for file source, must start with file://\", dsn)\n\t}\n\n\ts.logger = logger\n\ts.config = Configuration{}\n\n\tdsn = strings.TrimPrefix(dsn, \"file://\")\n\n\targs := strings.Split(dsn, \"?\")\n\n\tif args[0] == \"\" {\n\t\treturn errors.New(\"empty file:// DSN\")\n\t}\n\n\tif len(args) == 2 && args[1] != \"\" {\n\t\tparams, err := url.ParseQuery(args[1])\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not parse file args: %w\", err)\n\t\t}\n\n\t\tfor key, value := range params {\n\t\t\tswitch key {\n\t\t\tcase \"log_level\":\n\t\t\t\tif len(value) != 1 {\n\t\t\t\t\treturn errors.New(\"expected zero or one value for 'log_level'\")\n\t\t\t\t}\n\n\t\t\t\tlvl, err := log.ParseLevel(value[0])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"unknown level %s: %w\", value[0], err)","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/file/config.go#L146-L182","documentation":"DSN validation in the file datasource's ConfigureByDSN: after stripping the mandatory file:// prefix and splitting on '?', the path component (args[0]) is empty — the DSN names no file to tail (e.g. 'file://' or 'file://?log_level=debug').","triggerScenarios":"Thrown at pkg/acquisition/modules/file/config.go:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the path after the scheme: file:///var/log/nginx/access.log","Put options in the query string only after a real path: file:///path/to/log?log_level=debug"],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}