{"record":{"id":"b2bab3ad1f4a9e9e","repo":"docker/cli","slug":"hostname-is-empty","errorCode":null,"errorMessage":"hostname is empty","messagePattern":"hostname is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/connhelper/ssh/ssh.go","lineNumber":59,"sourceCode":"\t}\n\tif u.Scheme == \"\" {\n\t\treturn nil, errors.New(\"no scheme provided\")\n\t}\n\tif u.Scheme != \"ssh\" {\n\t\treturn nil, errors.New(\"incorrect scheme: \" + u.Scheme)\n\t}\n\n\tvar sp Spec\n\n\tif u.User != nil {\n\t\tsp.User = u.User.Username()\n\t\tif _, ok := u.User.Password(); ok {\n\t\t\treturn nil, errors.New(\"plain-text password is not supported\")\n\t\t}\n\t}\n\tsp.Host = u.Hostname()\n\tif sp.Host == \"\" {\n\t\treturn nil, errors.New(\"hostname is empty\")\n\t}\n\tsp.Port = u.Port()\n\tsp.Path = u.Path\n\tif u.RawQuery != \"\" {\n\t\treturn nil, fmt.Errorf(\"query parameters are not allowed: %q\", u.RawQuery)\n\t}\n\tif u.Fragment != \"\" {\n\t\treturn nil, fmt.Errorf(\"fragments are not allowed: %q\", u.Fragment)\n\t}\n\n\treturn &sp, nil\n}\n\n// Spec of SSH URL\ntype Spec struct {\n\tUser string\n\tHost string\n\tPort string","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/connhelper/ssh/ssh.go#L41-L77","documentation":"Returned by newSpec when u.Hostname() returns an empty string. An SSH connection needs a target host to dial; without one the generated ssh command line would be incomplete and the connection could not be established.","triggerScenarios":"Passing a URL like 'ssh:///path' (scheme but no host) or 'ssh://:22' (only a port). A URL that degenerates after parsing so the host portion is empty.","commonSituations":"Typing 'ssh://' without a hostname. A templated DOCKER_HOST whose host variable expanded to empty. Confusing an ssh URL with a unix socket path syntax.","solutions":["Provide a hostname: 'ssh://user@remote-host'.","If a port is needed, include the host: 'ssh://user@remote-host:2222'.","Check that any variable used for the host is non-empty before constructing the URL."],"exampleFix":"# before\nDOCKER_HOST=ssh://\n# after\nDOCKER_HOST=ssh://user@remote-host","handlingStrategy":"validation","validationCode":"u, err := url.Parse(host)\nif err != nil || u.Hostname() == \"\" {\n    return errors.New(\"DOCKER_HOST must include a hostname for ssh://\")\n}","typeGuard":"func hasHostname(s string) bool {\n    u, err := url.Parse(s)\n    return err == nil && u.Hostname() != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always include the hostname in ssh:// URLs.","Ensure templated host variables are non-empty.","Validate the URL with url.Parse before passing to the helper."],"tags":["ssh","connhelper","docker-host","url-parsing","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}