{"record":{"id":"30cda8a402144455","repo":"docker/cli","slug":"unable-to-parse-server-address-w","errorCode":null,"errorMessage":"unable to parse server address: %w","messagePattern":"unable to parse server address: %w","errorType":"validation","errorClass":"invalidParameterErr","httpStatus":null,"severity":"error","filePath":"internal/registry/service.go","lineNumber":45,"sourceCode":"\t\treturn nil, err\n\t}\n\treturn &Service{config: config}, nil\n}\n\n// Auth contacts the public registry with the provided credentials,\n// and returns OK if authentication was successful.\n// It can be used to verify the validity of a client's credentials.\nfunc (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, userAgent string) (token string, _ error) {\n\tregistryHostName := IndexHostname\n\n\tif authConfig.ServerAddress != \"\" {\n\t\tserverAddress := authConfig.ServerAddress\n\t\tif !strings.HasPrefix(serverAddress, \"https://\") && !strings.HasPrefix(serverAddress, \"http://\") {\n\t\t\tserverAddress = \"https://\" + serverAddress\n\t\t}\n\t\tu, err := url.Parse(serverAddress)\n\t\tif err != nil {\n\t\t\treturn \"\", invalidParam(fmt.Errorf(\"unable to parse server address: %w\", err))\n\t\t}\n\t\tregistryHostName = u.Host\n\t}\n\n\t// Lookup endpoints for authentication.\n\tendpoints, err := s.Endpoints(ctx, registryHostName)\n\tif err != nil {\n\t\tif errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn \"\", invalidParam(err)\n\t}\n\n\tvar lastErr error\n\tfor _, endpoint := range endpoints {\n\t\tauthToken, err := loginV2(ctx, authConfig, endpoint, userAgent)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) || errdefs.IsUnauthorized(err) {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/internal/registry/service.go#L27-L63","documentation":"Returned by Service.Auth when url.Parse fails on the normalized authConfig.ServerAddress (an https:// prefix is prepended if no scheme present). The parse error is wrapped with invalidParam. This guards against malformed server addresses before endpoint lookup.","triggerScenarios":"Calling Auth with a ServerAddress that is not a valid URL after scheme normalization — illegal characters, invalid escaping, malformed host.","commonSituations":"User types a registry address with spaces/special chars; programmatic AuthConfig with an unescaped address; trailing junk in config; using a value intended for another field.","solutions":["Correct the server address to a clean host[:port] (e.g. `registry.example.com:5000`).","If including a scheme, use http:// or https://; avoid unsupported schemes.","Sanitize/validate the address before passing it to Auth."],"exampleFix":"// before\nauth.ServerAddress = \"registry example com\"\n// after\nauth.ServerAddress = \"registry.example.com:5000\"","handlingStrategy":"validation","validationCode":"test := authConfig.ServerAddress\nif !strings.HasPrefix(test, \"http://\") && !strings.HasPrefix(test, \"https://\") { test = \"https://\" + test }\nif _, err := url.Parse(test); err != nil { return fmt.Errorf(\"bad server address: %w\", err) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize server addresses to plain host[:port].","Validate URLs at the trust boundary before calling Auth.","Avoid passing free-form user input straight to ServerAddress."],"tags":["registry","auth","url-parse","validation","server-address"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}