{"record":{"id":"9c35dd86ae8709ec","repo":"owasp-amass/amass","slug":"missing-hostname-in-database-uri","errorCode":null,"errorMessage":"missing hostname in database URI","messagePattern":"missing hostname in database URI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/engineapi.go","lineNumber":123,"sourceCode":"\treturn nil\n}\n\n// loadEngineURI takes the Engine API's URI as a string, parses it, and populates the EngAPI structure with the URI's components.\n// It performs validations to ensure the URI contains a valid scheme and hostname. If parsing fails or any validation check doesn't pass,\n// an error is returned. It also handles extracting authentication information and any additional options provided in the URI query.\nfunc (c *Config) loadEngineURI(apiURI string) error {\n\t// Parse the raw URI string to a url.URL object. If the URI is malformed, an error is returned.\n\tu, err := url.Parse(apiURI)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Check for valid scheme\n\tif u.Scheme == \"\" {\n\t\treturn fmt.Errorf(\"missing scheme 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\t// If the path is present in the URI and is more than just a \"/\", it's trimmed and used.\n\t// If the path is empty or just a \"/\", it defaults to an empty string.\n\tapiURIPath := \"\"\n\t// Only get the api file path name if it's not empty or a single slash\n\tif u.Path != \"\" && u.Path != \"/\" {\n\t\tapiURIPath = strings.TrimPrefix(u.Path, \"/\")\n\t}\n\t// Initialize a new EngAPI object with data from the parsed URI.\n\tapi := &EngAPI{\n\t\tURL:      apiURI,\n\t\tScheme:   u.Scheme,\n\t\tUsername: u.User.Username(),\n\t\tPath:     apiURIPath,\n\t\tHost:     u.Hostname(), // Hostname without port\n\t\tPort:     u.Port(),     // Get port\n\t}\n\t// If a password is set in the URI, it's extracted and stored in the EngAPI object.","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/engineapi.go#L105-L141","documentation":"loadEngineURI parsed the engine API URI but u.Hostname() is empty — the URI has a scheme yet no host (e.g. \"grpc:///path\" or a malformed authority section). Without a hostname the API endpoint cannot be reached, so the guard rejects it. Also exercised by TestLoadEngineEnvSettings_MissingEnvSettings when AMASS_ENGINE_HOST is unset.","triggerScenarios":"Thrown at config/engineapi.go:123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the host in the engine URI, e.g. \"grpc://127.0.0.1:2301\"","Set AMASS_ENGINE_HOST (and port) when configuring via environment variables","Check for empty url.URL.Hostname() before accepting user- or env-provided URIs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}