{"record":{"id":"a07bbf93394c3ce2","repo":"kubernetes/kops","slug":"error-downloading-file-q-v","errorCode":null,"errorMessage":"error downloading file %q: %v","messagePattern":"error downloading file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/assets/assetcopy/copyfile.go","lineNumber":114,"sourceCode":"\t\treturn fmt.Errorf(\"unable to transfer %q to %q: %v\", source, target, err)\n\t}\n\n\treturn nil\n}\n\n// transferFile downloads a file from the source location, validates the file matches the SHA,\n// and uploads the file to the target location.\nfunc transferFile(ctx context.Context, vfsContext *vfs.VFSContext, cluster *kops.Cluster, source string, target string, sha string) error {\n\t// TODO drop file to disk, as vfs reads file into memory.  We load kubelet into memory for instance.\n\t// TODO in s3 can we do a copy file ... would need to test\n\n\tdata, err := vfsContext.ReadFile(source)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"file not found %q: %v\", source, err)\n\t\t}\n\n\t\treturn fmt.Errorf(\"error downloading file %q: %v\", source, err)\n\t}\n\n\tobjectStore, err := buildVFSPath(target)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tuploadVFS, err := vfsContext.BuildVfsPath(objectStore)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building path %q: %v\", objectStore, err)\n\t}\n\n\tshaExtension, err := fileExtensionForSHA(sha)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tshaTarget := objectStore + shaExtension","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/assetcopy/copyfile.go#L96-L132","documentation":"Any non-NotExist failure reading the source asset through VFS is wrapped as 'error downloading file <source>: <reason>'. This covers HTTP errors other than 404, TLS failures, DNS failures, and cloud-storage API errors while fetching the canonical asset.","triggerScenarios":"vfsContext.ReadFile fails with e.g. 403 Forbidden, 500, connection timeout, bad TLS certificate, or S3/GCS API error when reading the canonical FileAsset URL during `kops get assets --copy`.","commonSituations":"Corporate proxy/firewall blocking storage.googleapis.com; expired or missing AWS/GCS credentials for a private source bucket; transient cloud-storage 5xx; hostname typos in a custom repository URL.","solutions":["Read the wrapped error for the concrete cause (timeout vs 403 vs TLS).","Test the source URL with curl from the same machine/network to reproduce.","Fix credentials (aws configure / GOOGLE_APPLICATION_CREDENTIALS) if the source is private.","Retry after network/proxy issues are resolved; consider running from a host with egress to the asset host."],"exampleFix":"// before\nerror downloading file \"https://storage.googleapis.com/...\": Get \"...\": dial tcp: lookup ...: no such host\n// after (fix DNS/proxy, then)\nexport HTTPS_PROXY=http://proxy.corp:3128\nkops get assets --copy ...","handlingStrategy":"retry","validationCode":"// Check basic reachability and auth before copying:\nresp, err := http.Get(sourceURL) // or cloud SDK HEAD for private buckets\nif err != nil { return err }\nif resp.StatusCode >= 400 { return fmt.Errorf(\"%s -> %d\", sourceURL, resp.StatusCode) }","typeGuard":null,"tryCatchPattern":"err := transferFile(ctx, vfsContext, cluster, source, target, sha)\nif err != nil && strings.Contains(err.Error(), \"error downloading file\") {\n    // transient network/storage errors: retry with backoff\n    return retryWithBackoff(3, time.Second, func() error {\n        return transferFile(ctx, vfsContext, cluster, source, target, sha)\n    })\n}","preventionTips":["Ensure egress/proxy settings allow the asset host (HTTPS_PROXY etc.)","Refresh cloud credentials before long copy runs","Distinguish 404 (missing file, error 784) from other statuses before retrying","Retry transient 5xx/timeouts with backoff"],"tags":["go","network","vfs","download"],"backgroundTag":"asset-download-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}