thanos-io/thanos · error
opening file
Error message
opening file
What it means
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.
Solutions
- Verify the file exists locally at the given path
- Check file permissions
- Retry after the file is restored/downloaded
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/block/metadata/hash.go:47 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/36ed846d0e42cd4f.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/block/metadata/hash.go:47
// ObjectHash stores the hash of an object in the object storage.
type ObjectHash struct {
Func HashFunc `json:"hashFunc"`
Value string `json:"value"`
}
// Equal returns true if two hashes are equal.
func (oh *ObjectHash) Equal(other *ObjectHash) bool {
return oh.Value == other.Value
}
// CalculateHash calculates the hash of the given type.
func CalculateHash(p string, hf HashFunc, logger log.Logger) (ObjectHash, error) {
switch hf {
case SHA256Func:
f, err := os.Open(filepath.Clean(p))
if err != nil {
return ObjectHash{}, errors.Wrap(err, "opening file")
}
defer runutil.CloseWithLogOnErr(logger, f, "closing %s", p)
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return ObjectHash{}, errors.Wrap(err, "copying")
}
return ObjectHash{
Func: SHA256Func,
Value: hex.EncodeToString(h.Sum(nil)),
}, nil
}
return ObjectHash{}, fmt.Errorf("hash function %v is not supported", hf)
}
View on GitHub (pinned to 35b8b99117)