{"record":{"id":"6a51240a5a1bf0ae","repo":"crowdsecurity/crowdsec","slug":"too-many-arguments-in-dsn","errorCode":null,"errorMessage":"too many arguments in DSN","messagePattern":"too many arguments in DSN","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/wineventlog/config_windows.go","lineNumber":203,"sourceCode":"\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 {\n\t\t\t\t\treturn errors.New(\"log_level must be a single value\")\n\t\t\t\t}\n\t\t\t\tlvl, err := log.ParseLevel(value[0])\n\t\t\t\tif err != nil {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/wineventlog/config_windows.go#L185-L221","documentation":"The wineventlog DSN format allows at most two '?'-separated segments: the event log file/channel and one query-string of parameters. More than one '?' produces more than two args, indicating a malformed DSN.","triggerScenarios":"Calling ConfigureByDSN with a DSN containing multiple '?' characters, e.g. wineventlog://Security?log_level=info?event_level=error, or an unencoded '?' inside a parameter value.","commonSituations":"Users appending options as extra '?key=value' pairs instead of joining them with '&' inside a single query string; pasting a full URL that itself contains '?' into the DSN; XPath queries with unescaped '?' characters.","solutions":["Join multiple parameters in one query string: wineventlog://Security?log_level=info&event_level=error","URL-encode any literal '?' inside parameter values (%3F)","Ensure the XPath query passed in the DSN does not contain a raw '?'"],"exampleFix":"// before\nwineventlog://Security?log_level=info?event_level=error\n// after\nwineventlog://Security?log_level=info&event_level=error","handlingStrategy":"validation","validationCode":"// Go: ensure only one '?' in the DSN\nif strings.Count(dsn, \"?\") > 1 {\n    return fmt.Errorf(\"wineventlog DSN allows at most one '?' separator; join params with '&'\")\n}","typeGuard":null,"tryCatchPattern":"if err := src.ConfigureByDSN(dsn); err != nil {\n    return fmt.Errorf(\"malformed wineventlog DSN %q: %w\", dsn, err)\n}","preventionTips":["Join multiple DSN parameters with '&' inside one query string","URL-encode literal '?' characters in parameter values","Use url.Values.Encode() to build the query portion"],"tags":["windows","acquisition","dsn","url","wineventlog"],"backgroundTag":"invalid-url-format","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"}