{"record":{"id":"2c8be7e278f25353","repo":"kubernetes/kops","slug":"unable-to-hash-file-q-downloaded-v","errorCode":null,"errorMessage":"unable to hash file %q downloaded: %v","messagePattern":"unable to hash file %q downloaded: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/assets/assetcopy/copyfile.go","lineNumber":146,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\tshaTarget := objectStore + shaExtension\n\tshaVFS, err := vfsContext.BuildVfsPath(shaTarget)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building path %q: %v\", shaTarget, err)\n\t}\n\n\tshaHash, err := hashing.FromString(strings.TrimSpace(sha))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to parse sha: %q, %v\", sha, err)\n\t}\n\n\tin := bytes.NewReader(data)\n\tdataHash, err := shaHash.Algorithm.Hash(in)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to hash file %q downloaded: %v\", source, err)\n\t}\n\n\tif !shaHash.Equal(dataHash) {\n\t\treturn fmt.Errorf(\"the sha value in %q does not match %q calculated value %q\", shaTarget, source, dataHash.String())\n\t}\n\n\tklog.Infof(\"uploading %q to %q\", source, objectStore)\n\tif err := writeFile(ctx, cluster, uploadVFS, data); err != nil {\n\t\treturn err\n\t}\n\n\tb := []byte(shaHash.Hex())\n\tif err := writeFile(ctx, cluster, shaVFS, b); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/assetcopy/copyfile.go#L128-L164","documentation":"After downloading the source asset into memory, transferFile hashes it with the declared algorithm (shaHash.Algorithm.Hash(bytes.NewReader(data))). If hashing itself errors (not a mismatch — a mismatch is a separate error), the task fails with 'unable to hash file <source> downloaded: <reason>'.","triggerScenarios":"The hash computation over the downloaded bytes returns an error — essentially only when the data reader fails mid-hash (rare, since data is an in-memory bytes.Reader), indicating an internal/library-level problem rather than a content mismatch.","commonSituations":"Very rare in practice; would appear alongside memory pressure or an unexpected failure in the hashing library's Hash implementation.","solutions":["Re-run the copy; this is not a content problem and is usually transient or environmental.","Check machine memory/disk health since the file was fully loaded into memory.","If reproducible, report with the kops version and the wrapped inner error.","As a workaround, ensure adequate resources for the machine running kops (large files are hashed in memory)."],"exampleFix":"// before\nunable to hash file \"https://.../kubelet\" downloaded: unexpected EOF\n// after\nkops get assets --copy ...  # retry on a healthy host with sufficient RAM","handlingStrategy":"retry","validationCode":"// Hashing over in-memory data rarely fails; verify available memory for large assets:\nif runtime.NumCPU() == 0 || /* e.g. constrained env */ checkMemLimit() {\n    log.Printf(\"insufficient resources for in-memory hashing of large assets\")\n}","typeGuard":null,"tryCatchPattern":"err := transferFile(ctx, vfsContext, cluster, source, target, sha)\nif err != nil && strings.Contains(err.Error(), \"unable to hash file\") {\n    return retryWithBackoff(3, time.Second, func() error {\n        return transferFile(ctx, vfsContext, cluster, source, target, sha)\n    })\n}","preventionTips":["Run kops on a host with enough RAM to hold the largest asset in memory","Retry — this failure is usually transient/environmental","Keep kops up to date to pick up hashing library fixes","If persistent, capture the inner error and file an issue with the kops version"],"tags":["go","sha","hashing","asset-copy"],"backgroundTag":"asset-hash-computation-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"}