{"id":"81a5bf1163fad978","repo":"docker/cli","slug":"invalid-proto-expected-tcp-s","errorCode":null,"errorMessage":"invalid proto, expected tcp: %s","messagePattern":"invalid proto, expected tcp: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/hosts.go","lineNumber":105,"sourceCode":"\t}\n\tif addr == \"\" {\n\t\taddr = defaultAddr\n\t}\n\treturn fmt.Sprintf(\"%s://%s\", proto, addr), nil\n}\n\n// ParseTCPAddr parses and validates that the specified address is a valid TCP\n// address. It returns a formatted TCP address, either using the address parsed\n// from tryAddr, or the contents of defaultAddr if tryAddr is a blank string.\n// tryAddr is expected to have already been Trim()'d\n// defaultAddr must be in the full `tcp://host:port` form\nfunc ParseTCPAddr(tryAddr string, defaultAddr string) (string, error) {\n\tif tryAddr == \"\" || tryAddr == \"tcp://\" {\n\t\treturn defaultAddr, nil\n\t}\n\taddr := strings.TrimPrefix(tryAddr, \"tcp://\")\n\tif strings.Contains(addr, \"://\") || addr == \"\" {\n\t\treturn \"\", fmt.Errorf(\"invalid proto, expected tcp: %s\", tryAddr)\n\t}\n\n\tdefaultAddr = strings.TrimPrefix(defaultAddr, \"tcp://\")\n\tdefaultHost, defaultPort, err := net.SplitHostPort(defaultAddr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t// url.Parse fails for trailing colon on IPv6 brackets on Go 1.5, but\n\t// not 1.4. See https://github.com/golang/go/issues/12200 and\n\t// https://github.com/golang/go/issues/6530.\n\tif strings.HasSuffix(addr, \"]:\") {\n\t\taddr += defaultPort\n\t}\n\n\tu, err := url.Parse(\"tcp://\" + addr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/hosts.go#L87-L123","documentation":"Error \"invalid proto, expected tcp: %s\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/hosts.go:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}