{"record":{"id":"6a7a1ee44feff04e","repo":"crowdsecurity/crowdsec","slug":"expected-zero-or-one-value-for-log-level-6a7a1e","errorCode":null,"errorMessage":"expected zero or one value for 'log_level'","messagePattern":"expected zero or one value for 'log_level'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/file/config.go","lineNumber":177,"sourceCode":"\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)\n\t\t\t\t}\n\n\t\t\t\ts.logger.Logger.SetLevel(lvl)\n\t\t\tcase \"max_buffer_size\":\n\t\t\t\tif len(value) != 1 {\n\t\t\t\t\treturn errors.New(\"expected zero or one value for 'max_buffer_size'\")\n\t\t\t\t}\n\n\t\t\t\tmaxBufferSize, err := strconv.Atoi(value[0])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse max_buffer_size %s: %w\", value[0], err)\n\t\t\t\t}\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/file/config.go#L159-L195","documentation":"DSN validation in file ConfigureByDSN: the log_level query parameter occurs more than once in the file:// DSN. url.ParseQuery produces a slice per key and the guard requires exactly one element before log.ParseLevel is applied.","triggerScenarios":"Thrown at pkg/acquisition/modules/file/config.go:177 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give log_level a single occurrence, e.g. file:///var/log/app.log?log_level=info","Use valid level names: trace, debug, info, warn/warning, error, fatal, panic"],"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-14T05:17:10.506Z"}