{"record":{"id":"6cbf84171a5c0f5c","repo":"owasp-amass/amass","slug":"unable-to-parse-database-uri-query-parameters-v","errorCode":null,"errorMessage":"unable to parse database URI query parameters: %v","messagePattern":"unable to parse database URI query parameters: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/graphdb.go","lineNumber":146,"sourceCode":"\tdb := &Database{\n\t\tPrimary:  true, // Set as primary, because it wouldn't be there otherwise.\n\t\tURL:      dbURI,\n\t\tSystem:   u.Scheme,\n\t\tUsername: u.User.Username(),\n\t\tDBName:   dbName,\n\t\tHost:     u.Hostname(), // Hostname without port\n\t\tPort:     u.Port(),     // Get port\n\t}\n\n\tpassword, isSet := u.User.Password()\n\tif isSet {\n\t\tdb.Password = password\n\t}\n\n\tif u.RawQuery != \"\" {\n\t\tqueryParams, err := url.ParseQuery(u.RawQuery)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to parse database URI query parameters: %v\", err)\n\t\t}\n\t\tdb.Options = queryParams.Encode() // Encode url.Values to a string\n\t}\n\n\tif c.GraphDBs == nil {\n\t\tc.GraphDBs = make([]*Database, 0)\n\t}\n\tc.GraphDBs = append(c.GraphDBs, db)\n\n\treturn nil\n}\n\n// LocalDatabaseSettings returns the Database for the local bolt store.\nfunc (c *Config) LocalDatabaseSettings(dbs []*Database) *Database {\n\tbolt := &Database{\n\t\tSystem:  \"local\",\n\t\tPrimary: true,\n\t\tURL:     OutputDirectory(c.Dir),","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/graphdb.go#L128-L164","documentation":"When the database URI contains a query string, loadDatabase parses it with url.ParseQuery to store the parameters as db.Options. Malformed query syntax (e.g. a bare '%' or missing '=') makes ParseQuery fail and this error is returned, wrapping the underlying parse error.","triggerScenarios":"A GraphDB URI whose RawQuery is not valid URL-encoded form data, e.g. 'neo4j://user:pass@host/db?flag%zz' or '?a=1&' with a stray invalid escape.","commonSituations":"Manually appending options to the URI without encoding; pasting a connection string where '?param=value' got truncated or contains unencoded characters like spaces or braces.","solutions":["Fix the query string so it is valid form encoding: key=value pairs joined by &, with special characters percent-encoded.","Remove the query string entirely if the options are not needed.","Test the query portion with url.ParseQuery in a scratch Go snippet to see the exact offending component (the wrapped %v error names it)."],"exampleFix":"// before\n\"database\": \"neo4j://user:pass@host/db?replicaSet=rs 0&tls=%zz\"\n// after\n\"database\": \"neo4j://user:pass@host/db?replicaSet=rs+0&tls=true\"","handlingStrategy":"validation","validationCode":"if i := strings.Index(dbURI, \"?\"); i >= 0 {\n    if _, err := url.ParseQuery(dbURI[i+1:]); err != nil {\n        return fmt.Errorf(\"invalid query params: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := loadDatabase(uri); err != nil {\n    var qe *url.EscapeError\n    if errors.As(err, &qe) || strings.Contains(err.Error(), \"query parameters\") {\n        return fmt.Errorf(\"percent-encode query values: %w\", err)\n    }\n}","preventionTips":["Build query strings with url.Values.Encode(), never by hand","Percent-encode values containing spaces, %, &","Keep DB options in a separate config section if the URI gets unwieldy"],"tags":["url","configuration","parsing"],"backgroundTag":"invalid-query-parameter","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}