{"record":{"id":"73713f216d7c1b52","repo":"henrygd/beszel","slug":"fingerprint-file-is-empty","errorCode":null,"errorMessage":"fingerprint file is empty","messagePattern":"fingerprint file is empty","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/fingerprint.go","lineNumber":72,"sourceCode":"\t\t\t\tcpuModel = getCpuModelFromCpuinfo()\n\t\t\t}\n\t\t}\n\t\tfingerprint = hostname + cpuModel\n\t}\n\n\tsum := sha256.Sum256([]byte(fingerprint))\n\treturn hex.EncodeToString(sum[:24])\n}\n\n// readFingerprint reads the saved fingerprint from the data directory.\nfunc readFingerprint(dataDir string) (string, error) {\n\tfp, err := os.ReadFile(filepath.Join(dataDir, fingerprintFileName))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\ts := strings.TrimSpace(string(fp))\n\tif s == \"\" {\n\t\treturn \"\", errors.New(\"fingerprint file is empty\")\n\t}\n\treturn s, nil\n}\n\n// SaveFingerprint writes the fingerprint to the data directory.\nfunc SaveFingerprint(dataDir, fingerprint string) error {\n\treturn os.WriteFile(filepath.Join(dataDir, fingerprintFileName), []byte(fingerprint), 0o644)\n}\n\n// DeleteFingerprint removes the saved fingerprint file from the data directory.\n// Returns nil if the file does not exist (idempotent).\nfunc DeleteFingerprint(dataDir string) error {\n\terr := os.Remove(filepath.Join(dataDir, fingerprintFileName))\n\tif errors.Is(err, os.ErrNotExist) {\n\t\treturn nil\n\t}\n\treturn err\n}","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/henrygd/beszel/blob/b38fb7dafa60812cc22e6a84ce313e94f1ce0a32/agent/fingerprint.go#L54-L90","documentation":"readFingerprint loads the fingerprint file from the data directory and trims whitespace. If the file reads successfully but contains nothing after trimming, it rejects the empty value with this error. It exists so callers like GetFingerprint fail fast instead of treating a blank file as a valid fingerprint.","triggerScenarios":"Calling agent.GetFingerprint() when the fingerprint file exists in the data dir but is 0 bytes, contains only whitespace/newlines, or was truncated by a failed SaveFingerprint/interrupted write.","commonSituations":"Disk-full conditions or crashes during first pairing that left a zero-length fingerprint file; manually creating the file empty in advance; a copy/restore step that preserved the filename but lost the content.","solutions":["Delete the empty fingerprint file and restart the agent so it regenerates a fingerprint via SaveFingerprint.","Verify the data directory is writable and has free space so the regenerated fingerprint persists.","After regenerating, re-approve/re-add the agent on the hub if the fingerprint pairing changed."],"exampleFix":"// before (empty file lingers, agent fails on startup)\n$ ls -l ~/.beszel/fingerprint\n-rw-r--r-- 0 bytes\n\n// after\n$ rm ~/.beszel/fingerprint\n$ sudo systemctl restart beszel-agent","handlingStrategy":"validation","validationCode":"info, err := os.Stat(filepath.Join(dataDir, \"fingerprint\"))\nif err == nil && info.Size() == 0 {\n    os.Remove(filepath.Join(dataDir, \"fingerprint\")) // force regeneration\n}","typeGuard":null,"tryCatchPattern":"fp, err := agent.GetFingerprint()\nif err != nil && err.Error() == \"fingerprint file is empty\" {\n    os.Remove(filepath.Join(dataDir, \"fingerprint\"))\n    if err := agent.SaveFingerprint(dataDir, newFingerprint()); err != nil {\n        log.Fatalf(\"regenerate fingerprint: %v\", err)\n    }\n}","preventionTips":["Never pre-create the fingerprint file manually; let SaveFingerprint write it.","Monitor disk space so saves are not truncated.","Ensure atomic/persisted storage for the data directory (no volatile tmpfs in production)."],"tags":["filesystem","fingerprint","empty-file"],"backgroundTag":"fingerprint-file-empty","analyzedSha":"b38fb7dafa60812cc22e6a84ce313e94f1ce0a32","analyzedAt":"2026-08-31T15:10:10.149Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}