wavetermdev/waveterm · error
failed to generate UUID: %w
Error message
failed to generate UUID: %w
What it means
MakeFileBackup generates a UUIDv7 (google/uuid package) to make the backup filename unique. uuid.NewV7() draws randomness from the system CSPRNG and can fail if that source is unavailable. This is extremely rare on Linux but occurs in restricted environments.
Source
Thrown at pkg/filebackup/filebackup.go:47
fileInfo, err := os.Stat(absFilePath)
if err != nil {
return "", fmt.Errorf("failed to stat file for backup: %w", err)
}
fileData, err := os.ReadFile(absFilePath)
if err != nil {
return "", fmt.Errorf("failed to read file for backup: %w", err)
}
dir := filepath.Dir(absFilePath)
basename := filepath.Base(absFilePath)
hash := sha256.Sum256([]byte(dir))
dirHash8 := hex.EncodeToString(hash[:])[:8]
uuidV7, err := uuid.NewV7()
if err != nil {
return "", fmt.Errorf("failed to generate UUID: %w", err)
}
uuidStr := uuidV7.String()
now := time.Now()
dateStr := now.Format("2006-01-02")
backupDir := filepath.Join(wavebase.GetWaveCachesDir(), "waveai-backups", dateStr)
err = os.MkdirAll(backupDir, 0700)
if err != nil {
return "", fmt.Errorf("failed to create backup directory: %w", err)
}
backupName := fmt.Sprintf("%s.%s.%s.bak", basename, dirHash8, uuidStr)
backupPath := filepath.Join(backupDir, backupName)
err = os.WriteFile(backupPath, fileData, 0600)
if err != nil {
return "", fmt.Errorf("failed to write backup file: %w", err)View on GitHub (pinned to a4447c1563)
Solutions
- Retry the operation once entropy is available
- Check that /dev/urandom exists and is accessible inside the container/sandbox
- Inspect seccomp/apparmor policies blocking the getrandom syscall
- Verify the google/uuid dependency is intact (go mod tidy / go mod download)
Defensive patterns
Strategy: retry
Validate before calling
if _, err := os.Stat("/dev/urandom"); err != nil {
return fmt.Errorf("no entropy source available for uuid generation")
} Try / catch
backupPath, err := filebackup.MakeFileBackup(path)
if err != nil && strings.Contains(err.Error(), "failed to generate UUID") {
// retry after entropy is available; check container device access
backupPath, err = filebackup.MakeFileBackup(path)
} Prevention
- Ensure /dev/urandom is present in containers running Wave
- Review seccomp/apparmor policies for getrandom blocking
- Avoid running at the instant of boot before entropy initialization
- Keep the google/uuid dependency up to date
When it happens
Trigger: uuid.NewV7() returns non-nil err — the OS random source (/dev/urandom, getrandom) is unavailable or the entropy pool is exhausted at boot.
Common situations: Containers/sandboxes without /dev/urandom; very early boot before entropy initialization; seccomp policies blocking getrandom syscall.
Related errors
- generating badge id: %v
- Invalid UUID format
- beginning of file
- procinfo: process not found
- integer overflow
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/6ef6c02811306b22.
Report an issue: GitHub.