{"record":{"id":"01f510c7f25e8186","repo":"owasp-amass/amass","slug":"missing-hostname-in-database-uri-01f510","errorCode":null,"errorMessage":"missing hostname in database URI","messagePattern":"missing hostname in database URI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/graphdb.go","lineNumber":119,"sourceCode":"\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,\n\t\tHost:     u.Hostname(), // Hostname without port\n\t\tPort:     u.Port(),     // Get port\n\t}\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/graphdb.go#L101-L137","documentation":"loadDatabase parsed the database URI but u.Hostname() returned empty: the URI has a scheme and username yet no host component (e.g. \"postgres://user@/dbname\"). The graph database server address is mandatory, so the guard rejects the URI before any connection is attempted.","triggerScenarios":"A configured URI missing the host, e.g. 'neo4j://user:pass@/db' or 'neo4j://user:pass@' reaching loadDatabase.","commonSituations":"Copy-paste mistakes that delete the host portion; a config template with a placeholder host that was never filled in; Unix-socket style URIs that this parser does not understand.","solutions":["Add the host to the URI: neo4j://user:pass@localhost:7687/db.","If using a socket/file-based DB, use the scheme/host syntax the driver actually supports instead of a bare path.","Print the parsed URI parts (scheme, host, path) in a quick script to confirm what the config resolves to."],"exampleFix":"// before\n\"database\": \"neo4j://user:pass@/mydb\"\n// after\n\"database\": \"neo4j://user:pass@localhost:7687/mydb\"","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(dbURI)\nif u.Hostname() == \"\" {\n    return errors.New(\"database URI must include a hostname\")\n}","typeGuard":null,"tryCatchPattern":"if err := loadDatabase(uri); err != nil {\n    if strings.Contains(err.Error(), \"missing hostname\") {\n        return fmt.Errorf(\"check host portion of %q\", uri)\n    }\n}","preventionTips":["Template the host from a variable instead of hand-editing","Validate URI host before saving config","Avoid placeholder values like <host> reaching runtime"],"tags":["url","configuration","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}