{"record":{"id":"f02384650f5313e5","repo":"benbjohnson/litestream","slug":"hash-temp-name-w","errorCode":null,"errorMessage":"hash temp name: %w","messagePattern":"hash temp name: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"vfs.go","lineNumber":384,"sourceCode":"\tif name == \"\" {\n\t\treturn \"\"\n\t}\n\tname = filepath.Clean(name)\n\tif name == \".\" || name == string(filepath.Separator) {\n\t\treturn \"\"\n\t}\n\treturn name\n}\n\nfunc tempFilenameFromCanonical(canonical string) (string, error) {\n\tbase := filepath.Base(canonical)\n\tif base == \".\" || base == string(filepath.Separator) {\n\t\treturn \"\", fmt.Errorf(\"invalid temp file name: %q\", canonical)\n\t}\n\n\th := fnv.New64a()\n\tif _, err := h.Write([]byte(canonical)); err != nil {\n\t\treturn \"\", fmt.Errorf(\"hash temp name: %w\", err)\n\t}\n\treturn fmt.Sprintf(\"%s-%016x\", base, h.Sum64()), nil\n}\n\nfunc (vfs *VFS) openTempFile(name string, flags sqlite3vfs.OpenFlag) (sqlite3vfs.File, sqlite3vfs.OpenFlag, error) {\n\tdir, err := vfs.ensureTempDir()\n\tif err != nil {\n\t\treturn nil, flags, err\n\t}\n\tdeleteOnClose := flags&sqlite3vfs.OpenDeleteOnClose != 0 || name == \"\"\n\tvar f *os.File\n\tvar onClose func()\n\tif name == \"\" {\n\t\tf, err = os.CreateTemp(dir, \"temp-*\")\n\t\tif err != nil {\n\t\t\treturn nil, flags, sqlite3vfs.CantOpenError\n\t\t}\n\t} else {","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L366-L402","documentation":"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.","triggerScenarios":"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.","commonSituations":"Developers seeing this in code review or coverage reports; practically never encountered at runtime by users.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"hash temp name\") {\n    // unreachable with stdlib fnv; treat as a bug and report\n}","preventionTips":["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."],"tags":["go","hashing","defensive-code","vfs"],"backgroundTag":"internal-invariant-violation","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}