{"record":{"id":"3ad1195670b97f72","repo":"thanos-io/thanos","slug":"copying","errorCode":null,"errorMessage":"copying","messagePattern":"copying","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/metadata/hash.go","lineNumber":54,"sourceCode":"// Equal returns true if two hashes are equal.\nfunc (oh *ObjectHash) Equal(other *ObjectHash) bool {\n\treturn oh.Value == other.Value\n}\n\n// CalculateHash calculates the hash of the given type.\nfunc CalculateHash(p string, hf HashFunc, logger log.Logger) (ObjectHash, error) {\n\tswitch hf {\n\tcase SHA256Func:\n\t\tf, err := os.Open(filepath.Clean(p))\n\t\tif err != nil {\n\t\t\treturn ObjectHash{}, errors.Wrap(err, \"opening file\")\n\t\t}\n\t\tdefer runutil.CloseWithLogOnErr(logger, f, \"closing %s\", p)\n\n\t\th := sha256.New()\n\n\t\tif _, err := io.Copy(h, f); err != nil {\n\t\t\treturn ObjectHash{}, errors.Wrap(err, \"copying\")\n\t\t}\n\n\t\treturn ObjectHash{\n\t\t\tFunc:  SHA256Func,\n\t\t\tValue: hex.EncodeToString(h.Sum(nil)),\n\t\t}, nil\n\t}\n\treturn ObjectHash{}, fmt.Errorf(\"hash function %v is not supported\", hf)\n\n}\n","sourceCodeStart":36,"sourceCodeEnd":65,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/metadata/hash.go#L36-L65","documentation":"Wraps io.Copy feeding the file into the sha256 hasher in CalculateHash: reading the file's bytes failed mid-stream (I/O error, file truncated concurrently). The partial digest is discarded and hashing fails.","triggerScenarios":"Thrown at pkg/block/metadata/hash.go:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk health for read errors","Verify the file is not truncated or concurrently written","Retry hashing the file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}