{"record":{"id":"afe498bc84ef7f35","repo":"kubernetes/kops","slug":"error-fetching-q-v","errorCode":null,"errorMessage":"error fetching %q: %v","messagePattern":"error fetching %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/context.go","lineNumber":268,"sourceCode":"// It will retry a few times on a 500 class error\nfunc (c *VFSContext) readHTTPLocation(httpURL string, httpHeaders map[string]string, opts vfsOptions) ([]byte, error) {\n\tvar body []byte\n\n\tdone, err := RetryWithBackoff(opts.backoff, func() (bool, error) {\n\t\tklog.V(4).Infof(\"Performing HTTP request: GET %s\", httpURL)\n\t\treq, err := http.NewRequest(\"GET\", httpURL, nil)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tfor k, v := range httpHeaders {\n\t\t\treq.Header.Add(k, v)\n\t\t}\n\t\tresponse, err := http.DefaultClient.Do(req)\n\t\tif response != nil {\n\t\t\tdefer response.Body.Close()\n\t\t}\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"error fetching %q: %v\", httpURL, err)\n\t\t}\n\t\tbody, err = io.ReadAll(response.Body)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"error reading response for %q: %v\", httpURL, err)\n\t\t}\n\t\tif response.StatusCode == 404 {\n\t\t\t// We retry on 404s in case of eventual consistency\n\t\t\treturn false, os.ErrNotExist\n\t\t}\n\t\tif response.StatusCode >= 500 && response.StatusCode <= 599 {\n\t\t\t// Retry on 5XX errors\n\t\t\treturn false, fmt.Errorf(\"unexpected response code %q for %q: %v\", response.Status, httpURL, string(body))\n\t\t}\n\n\t\tif response.StatusCode == 200 {\n\t\t\treturn true, nil\n\t\t}\n","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/context.go#L250-L286","documentation":"readHTTPLocation issues a GET via http.DefaultClient (with backoff retries). If the transport itself fails - DNS failure, connection refused/reset, TLS error, timeout - the network error is wrapped as 'error fetching <url>'. The retry loop retries this condition up to the backoff step count before returning.","triggerScenarios":"ReadFile with http(s):// or metadata://gce|digitalocean|openstack URLs when the server is down/unreachable, DNS fails, TLS handshake fails, or the request times out; also any http.NewRequest-level failure reaching Do.","commonSituations":"Wrong hostname/port in a channel or addon URL; corporate proxy required but not configured (HTTP_PROXY unset); IMDS endpoint blocked; TLS interception with an untrusted CA; server temporarily down while the 5-step backoff exhausts.","solutions":["Check reachability: `curl -v <url>` from the same host to see the underlying transport error","Fix DNS/hostname or use the correct IP/endpoint","Configure proxy env vars (HTTP_PROXY/HTTPS_PROXY) if egress requires a proxy","Fix TLS trust (install CA) if the error is a certificate failure","Increase the backoff (WithBackoff option) for slow/flaky endpoints"],"exampleFix":"// before\n// no proxy set, fetch fails behind corporate firewall\nresp, err := vfs.Context.ReadFile(\"https://addons.example.org/addons.yaml\")\n// after\nos.Setenv(\"HTTPS_PROXY\", \"http://proxy.corp:3128\")\nresp, err := vfs.Context.ReadFile(\"https://addons.example.org/addons.yaml\", vfs.WithBackoff(wait.Backoff{Duration: time.Second, Factor: 2, Steps: 8}))","handlingStrategy":"retry","validationCode":"func urlReachable(rawURL string) error {\n\tu, err := url.Parse(rawURL)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif u.Scheme != \"http\" && u.Scheme != \"https\" {\n\t\treturn fmt.Errorf(\"unexpected scheme %q\", u.Scheme)\n\t}\n\treturn nil // reachability itself can only be probed by attempting the fetch\n}","typeGuard":"func isFetchableURL(rawURL string) bool {\n\tu, err := url.Parse(rawURL)\n\treturn err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\") && u.Host != \"\"\n}","tryCatchPattern":"err := wait.ExponentialBackoff(wait.Backoff{Duration: time.Second, Factor: 2, Steps: 5}, func() (bool, error) {\n\t_, err := vfs.Context.ReadFile(loc)\n\tif err != nil && strings.Contains(err.Error(), \"error fetching\") {\n\t\treturn false, nil // transient transport failure - retry\n\t}\n\treturn err == nil, err\n})","preventionTips":["Configure HTTP_PROXY/HTTPS_PROXY when behind a corporate proxy","Probe the URL with curl before long-running operations that depend on it","Ensure DNS and TLS trust are correct on the host running kOps","Use a highly available host (CDN/LB) for addon/channel sources"],"tags":["network","http","fetch"],"backgroundTag":"http-request-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}