{"record":{"id":"6ef6c02811306b22","repo":"wavetermdev/waveterm","slug":"failed-to-generate-uuid-w","errorCode":null,"errorMessage":"failed to generate UUID: %w","messagePattern":"failed to generate UUID: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/filebackup/filebackup.go","lineNumber":47,"sourceCode":"\tfileInfo, err := os.Stat(absFilePath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to stat file for backup: %w\", err)\n\t}\n\n\tfileData, err := os.ReadFile(absFilePath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to read file for backup: %w\", err)\n\t}\n\n\tdir := filepath.Dir(absFilePath)\n\tbasename := filepath.Base(absFilePath)\n\n\thash := sha256.Sum256([]byte(dir))\n\tdirHash8 := hex.EncodeToString(hash[:])[:8]\n\n\tuuidV7, err := uuid.NewV7()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to generate UUID: %w\", err)\n\t}\n\tuuidStr := uuidV7.String()\n\n\tnow := time.Now()\n\tdateStr := now.Format(\"2006-01-02\")\n\n\tbackupDir := filepath.Join(wavebase.GetWaveCachesDir(), \"waveai-backups\", dateStr)\n\terr = os.MkdirAll(backupDir, 0700)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create backup directory: %w\", err)\n\t}\n\n\tbackupName := fmt.Sprintf(\"%s.%s.%s.bak\", basename, dirHash8, uuidStr)\n\tbackupPath := filepath.Join(backupDir, backupName)\n\n\terr = os.WriteFile(backupPath, fileData, 0600)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to write backup file: %w\", err)","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/filebackup/filebackup.go#L29-L65","documentation":"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.","triggerScenarios":"uuid.NewV7() returns non-nil err — the OS random source (/dev/urandom, getrandom) is unavailable or the entropy pool is exhausted at boot.","commonSituations":"Containers/sandboxes without /dev/urandom; very early boot before entropy initialization; seccomp policies blocking getrandom syscall.","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)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, err := os.Stat(\"/dev/urandom\"); err != nil {\n    return fmt.Errorf(\"no entropy source available for uuid generation\")\n}","typeGuard":null,"tryCatchPattern":"backupPath, err := filebackup.MakeFileBackup(path)\nif err != nil && strings.Contains(err.Error(), \"failed to generate UUID\") {\n    // retry after entropy is available; check container device access\n    backupPath, err = filebackup.MakeFileBackup(path)\n}","preventionTips":["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"],"tags":["uuid","randomness","entropy","go"],"backgroundTag":"uuid-generation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}