JuliusBrussee/caveman · error
native session key write
Error message
native session key write: %w
What it means
The O_EXCL create of session.key succeeded but writing the 32 bytes failed; the code closes the fd and deletes the partial file, so no corrupt key is ever left behind. The wrapped error is typically ENOSPC (disk full), EDQUOT (quota exceeded), or EIO from failing or removable storage. A clean retry succeeds once space exists.
Solutions
- Free space on the volume holding home (df -h <home>) or raise the quota
- Re-run startup — the partial file was already removed so the retry mints cleanly
- Point CAVEMAN_HOME at a volume with headroom
- If the error is EIO, check dmesg and the device's SMART health
Defensive patterns
Strategy: try-catch
Validate before calling
func hasFreeSpace(path string, want uint64) error {
var st syscall.Statfs_t
if err := syscall.Statfs(path, &st); err != nil {
return err
}
if free := st.Bavail * uint64(st.Bsize); free < want {
return fmt.Errorf("only %d bytes free under %s — key creation needs %d", free, path, want)
}
return nil
}
// before first-startup key creation
if err := hasFreeSpace(home, 1<<20); err != nil {
return err
} Try / catch
key, err := nativeruntime.LoadOrCreateSessionKey(home)
if err != nil {
if errors.Is(err, syscall.ENOSPC) || errors.Is(err, syscall.EDQUOT) {
// clean state guaranteed: the partial file was already removed — safe to retry after freeing space
log.Print("free disk space or raise the quota, then restart")
}
return err
} Prevention
- Run deployments with disk-space alerts well above zero so key creation never races a full volume
- Point CAVEMAN_HOME at a volume with headroom instead of a full root partition
- Treat ENOSPC/EDQUOT on first startup as transient: the function self-cleans, so a restart after cleanup is sufficient
- For quota-managed network homes, request at least a few MB of slack
When it happens
Trigger: First-ever startup on a 100%-full volume; user quota exceeded on a network home; a flaky USB/removable drive holding CAVEMAN_HOME; an NFS stale file handle surfacing during the write.
Common situations: Laptops with full disks; shared hosts with per-user quotas; first run right after restoring an image onto a small partition.
Related errors
- native session key close
- native session key sync
- inspect sqlite parent ACL
- inspect sqlite parent
- kms: read response
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/5c799a10655ca35d.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/internal/nativeruntime/marker.go:41
func LoadOrCreateSessionKey(home string) ([]byte, error) {
dir := filepath.Join(home, "runtime")
if err := os.MkdirAll(dir, 0o700); err != nil {
return nil, fmt.Errorf("native session key mkdir: %w", err)
}
if err := os.Chmod(dir, 0o700); err != nil {
return nil, fmt.Errorf("native session key chmod dir: %w", err)
}
path := filepath.Join(dir, "session.key")
key := make([]byte, sessionKeyBytes)
if _, err := rand.Read(key); err != nil {
return nil, fmt.Errorf("native session key random: %w", err)
}
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600)
if err == nil {
if _, writeErr := file.Write(key); writeErr != nil {
_ = file.Close()
_ = os.Remove(path)
return nil, fmt.Errorf("native session key write: %w", writeErr)
}
if syncErr := file.Sync(); syncErr != nil {
_ = file.Close()
_ = os.Remove(path)
return nil, fmt.Errorf("native session key sync: %w", syncErr)
}
if closeErr := file.Close(); closeErr != nil {
return nil, fmt.Errorf("native session key close: %w", closeErr)
}
return key, nil
}
if !errors.Is(err, os.ErrExist) {
return nil, fmt.Errorf("native session key create: %w", err)
}
key, err = os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("native session key read: %w", err)
}View on GitHub (pinned to 766dce6b13)