{"record":{"id":"8cc048f947274edb","repo":"crowdsecurity/crowdsec","slug":"empty-wineventlog-dsn","errorCode":null,"errorMessage":"empty wineventlog:// DSN","messagePattern":"empty wineventlog:// DSN","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/wineventlog/config_windows.go","lineNumber":199,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc (s *Source) ConfigureByDSN(ctx context.Context, dsn string, labels map[string]string, logger *log.Entry, uuid string) error {\n\tif !strings.HasPrefix(dsn, \"wineventlog://\") {\n\t\treturn fmt.Errorf(\"invalid DSN %s for wineventlog source, must start with wineventlog://\", dsn)\n\t}\n\n\ts.logger = logger\n\ts.config = Configuration{}\n\n\tdsn = strings.TrimPrefix(dsn, \"wineventlog://\")\n\n\targs := strings.Split(dsn, \"?\")\n\n\tif args[0] == \"\" {\n\t\treturn errors.New(\"empty wineventlog:// DSN\")\n\t}\n\n\tif len(args) > 2 {\n\t\treturn errors.New(\"too many arguments in DSN\")\n\t}\n\n\ts.config.EventFile = args[0]\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(\"failed to parse DSN parameters: %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 {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/wineventlog/config_windows.go#L181-L217","documentation":"ConfigureByDSN parses DSN strings of the form wineventlog://<event_file>[?<params>]. After stripping the scheme and splitting on '?', an empty first segment means no event log file/channel was specified, so the function rejects the DSN.","triggerScenarios":"Calling ConfigureByDSN with 'wineventlog://' or 'wineventlog://?log_level=info' — the part before '?' (the event log name) is empty.","commonSituations":"A generated or templated DSN where the channel variable was empty; copying a URL-style DSN and dropping the channel name; whitespace-only or stripped arguments in a script assembling the DSN.","solutions":["Include the Windows event log channel in the DSN, e.g. wineventlog://Security","Verify the variable holding the channel name is not empty in scripts/templates","Prefer a YAML acquisition file with event_channel if the DSN keeps coming out empty"],"exampleFix":"// before\nConfigureByDSN(\"wineventlog://\")\n// after\nConfigureByDSN(\"wineventlog://Security?log_level=info\")","handlingStrategy":"validation","validationCode":"// Go: check DSN before calling ConfigureByDSN\ndsn = strings.TrimPrefix(dsn, \"wineventlog://\")\nname := strings.Split(dsn, \"?\")[0]\nif name == \"\" {\n    return fmt.Errorf(\"wineventlog DSN requires an event log channel\")\n}","typeGuard":null,"tryCatchPattern":"if err := src.ConfigureByDSN(dsn); err != nil {\n    return fmt.Errorf(\"invalid wineventlog DSN %q: %w\", dsn, err)\n}","preventionTips":["Build DSNs from templates with non-empty, validated channel names","Prefer YAML acquisition config over DSN strings where possible","Test DSN assembly with sample values in CI"],"tags":["windows","acquisition","dsn","wineventlog"],"backgroundTag":"empty-required-field","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"}