{"record":{"id":"36ed846d0e42cd4f","repo":"thanos-io/thanos","slug":"opening-file","errorCode":null,"errorMessage":"opening file","messagePattern":"opening file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/metadata/hash.go","lineNumber":47,"sourceCode":"\n// ObjectHash stores the hash of an object in the object storage.\ntype ObjectHash struct {\n\tFunc  HashFunc `json:\"hashFunc\"`\n\tValue string   `json:\"value\"`\n}\n\n// 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":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/metadata/hash.go#L29-L65","documentation":"Wraps os.Open in CalculateHash's SHA-256 branch: the local file whose hash is being computed (block file path p) could not be opened — missing, permission-denied, or a directory. Hashing for upload verification cannot proceed.","triggerScenarios":"Thrown at pkg/block/metadata/hash.go:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the file exists locally at the given path","Check file permissions","Retry after the file is restored/downloaded"],"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"}