{"record":{"id":"f8f6b1363f9f5342","repo":"owasp-amass/amass","slug":"missing-username-in-database-uri","errorCode":null,"errorMessage":"missing username in database URI","messagePattern":"missing username in database URI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/graphdb.go","lineNumber":115,"sourceCode":"\tif c.GraphDBs == nil {\n\t\tc.GraphDBs = make([]*Database, 0)\n\t}\n\tc.GraphDBs = append(c.GraphDBs, db)\n\treturn nil\n}\n\nfunc (c *Config) loadDatabase(dbURI string) error {\n\tu, err := url.Parse(dbURI)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Check for valid scheme (database type)\n\tif u.Scheme == \"\" {\n\t\treturn fmt.Errorf(\"missing scheme in database URI\")\n\t}\n\t// Check for non-empty username\n\tif u.User == nil || u.User.Username() == \"\" {\n\t\treturn fmt.Errorf(\"missing username in database URI\")\n\t}\n\t// Check for reachable hostname\n\tif u.Hostname() == \"\" {\n\t\treturn fmt.Errorf(\"missing hostname in database URI\")\n\t}\n\n\tdbName := \"\"\n\t// Only get the database name if it's not empty or a single slash\n\tif u.Path != \"\" && u.Path != \"/\" {\n\t\tdbName = strings.TrimPrefix(u.Path, \"/\")\n\t}\n\n\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,","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/graphdb.go#L97-L133","documentation":"loadDatabase requires the database URI to carry credentials; after parsing, if u.User is nil or the username part is empty, it returns this error. The library enforces authenticated connections to the graph database.","triggerScenarios":"A configured URI like 'neo4j://localhost:7687/db' (no userinfo) or 'neo4j://:password@host/db' (empty username) reaches loadDatabase.","commonSituations":"Storing credentials separately and forgetting the user:pass@ userinfo; password contains characters like @ or / that were not percent-encoded and broke parsing; config migration dropped the userinfo.","solutions":["Embed credentials in the URI userinfo: neo4j://user:password@host:7687/db.","Percent-encode special characters in the password (e.g. @ -> %40, # -> %23).","Verify with url.Parse that u.User.Username() is non-empty before saving the config."],"exampleFix":"// before\n\"database\": \"neo4j://localhost:7687/mydb\"\n// after\n\"database\": \"neo4j://user:p%40ss@localhost:7687/mydb\"","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(dbURI)\nif u.User == nil || u.User.Username() == \"\" {\n    return errors.New(\"database URI must include username in userinfo\")\n}","typeGuard":null,"tryCatchPattern":"if err := loadDatabase(uri); err != nil {\n    if strings.Contains(err.Error(), \"missing username\") {\n        return fmt.Errorf(\"add user:pass@ to URI: %w\", err)\n    }\n}","preventionTips":["Include user:password@ userinfo in every DB URI","Percent-encode special characters in passwords","Keep credentials in env/secret stores and template them into the URI"],"tags":["url","configuration","credentials"],"backgroundTag":"missing-credentials","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"}