{"record":{"id":"b7246e9cd9cf3422","repo":"JuliusBrussee/caveman","slug":"native-session-key-sync-w","errorCode":null,"errorMessage":"native session key sync: %w","messagePattern":"native session key sync: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/nativeruntime/marker.go","lineNumber":46,"sourceCode":"\tif err := os.Chmod(dir, 0o700); err != nil {\n\t\treturn nil, fmt.Errorf(\"native session key chmod dir: %w\", err)\n\t}\n\tpath := filepath.Join(dir, \"session.key\")\n\tkey := make([]byte, sessionKeyBytes)\n\tif _, err := rand.Read(key); err != nil {\n\t\treturn nil, fmt.Errorf(\"native session key random: %w\", err)\n\t}\n\tfile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600)\n\tif err == nil {\n\t\tif _, writeErr := file.Write(key); writeErr != nil {\n\t\t\t_ = file.Close()\n\t\t\t_ = os.Remove(path)\n\t\t\treturn nil, fmt.Errorf(\"native session key write: %w\", writeErr)\n\t\t}\n\t\tif syncErr := file.Sync(); syncErr != nil {\n\t\t\t_ = file.Close()\n\t\t\t_ = os.Remove(path)\n\t\t\treturn nil, fmt.Errorf(\"native session key sync: %w\", syncErr)\n\t\t}\n\t\tif closeErr := file.Close(); closeErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"native session key close: %w\", closeErr)\n\t\t}\n\t\treturn key, nil\n\t}\n\tif !errors.Is(err, os.ErrExist) {\n\t\treturn nil, fmt.Errorf(\"native session key create: %w\", err)\n\t}\n\tkey, err = os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"native session key read: %w\", err)\n\t}\n\tif len(key) != sessionKeyBytes {\n\t\treturn nil, fmt.Errorf(\"native session key length = %d, want %d\", len(key), sessionKeyBytes)\n\t}\n\tif err := os.Chmod(path, 0o600); err != nil {\n\t\treturn nil, fmt.Errorf(\"native session key chmod: %w\", err)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/proxy/internal/nativeruntime/marker.go#L28-L64","documentation":"After a successful write of the session key, file.Sync (fsync) failed before the key was acknowledged. Sync guarantees the key survives a crash before callers rely on it for HMAC session markers; on failure the file is removed so no half-durable key is trusted. Common on filesystems with broken fsync (some network/overlay mounts) or failing disks.","triggerScenarios":"home on NFS/CIFS/overlayfs where fsync returns EIO/ENOTSUP; failing disk or degraded RAID; virtual disk briefly detached.","commonSituations":"Home directory on a network mount; Docker Desktop file-sharing mounts; early signs of disk failure.","solutions":["Move the caveman home directory to a local filesystem with working fsync","Check dmesg/SMART for underlying disk errors if local","Retry startup after remounting a flaky network volume"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func fsyncWorks(dir string) error {\n    f, err := os.CreateTemp(dir, \".fsync-probe-*\")\n    if err != nil { return err }\n    defer os.Remove(f.Name())\n    defer f.Close()\n    return f.Sync()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place the caveman home on a local filesystem with real fsync","Avoid NFS/CIFS/overlay for key material","Monitor SMART/dmesg for EIO patterns preceding sync failures"],"tags":["filesystem","durability","nativeruntime","session-key"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}