benbjohnson/litestream · info
hash temp name: %w
Error message
hash temp name: %w
What it means
tempFilenameFromCanonical appends an FNV-64a hash of the canonical name to the temp file base to keep names deterministic and collision-free. This error wraps a failure from hash.Write. In practice hash.Hash Write on a pure in-memory implementation never fails, so this error is effectively unreachable defensive code, but the API surface requires handling the error return.
Source
Thrown at vfs.go:384
if name == "" {
return ""
}
name = filepath.Clean(name)
if name == "." || name == string(filepath.Separator) {
return ""
}
return name
}
func tempFilenameFromCanonical(canonical string) (string, error) {
base := filepath.Base(canonical)
if base == "." || base == string(filepath.Separator) {
return "", fmt.Errorf("invalid temp file name: %q", canonical)
}
h := fnv.New64a()
if _, err := h.Write([]byte(canonical)); err != nil {
return "", fmt.Errorf("hash temp name: %w", err)
}
return fmt.Sprintf("%s-%016x", base, h.Sum64()), nil
}
func (vfs *VFS) openTempFile(name string, flags sqlite3vfs.OpenFlag) (sqlite3vfs.File, sqlite3vfs.OpenFlag, error) {
dir, err := vfs.ensureTempDir()
if err != nil {
return nil, flags, err
}
deleteOnClose := flags&sqlite3vfs.OpenDeleteOnClose != 0 || name == ""
var f *os.File
var onClose func()
if name == "" {
f, err = os.CreateTemp(dir, "temp-*")
if err != nil {
return nil, flags, sqlite3vfs.CantOpenError
}
} else {View on GitHub (pinned to 4ed7a308f6)
Solutions
- No action needed — this is defensive error handling of an infallible in-memory hash write.
- If it ever appears, check for exotic build tags or a replaced hash implementation in the module graph.
Defensive patterns
Strategy: try-catch
Try / catch
if err != nil && strings.Contains(err.Error(), "hash temp name") {
// unreachable with stdlib fnv; treat as a bug and report
} Prevention
- No user action required; error path is defensive only.
- Pin the standard library hash implementation (no exotic replaces).
- Keep code coverage to document the path as defensive.
When it happens
Trigger: Called from openTempFile for every temp/transient/journal file open; would only surface if fnv.New64a's Write returned a non-nil error, which does not occur with the standard library implementation.
Common situations: Developers seeing this in code review or coverage reports; practically never encountered at runtime by users.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- create temp dir for hydration: %w
- cannot delete vfs file
- invalid temp file name: %q
- temp file not tracked
- clear write buffer: %w
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/f02384650f5313e5.
Report an issue: GitHub.