{"record":{"id":"4b7c4146ed2919bc","repo":"MHSanaei/3x-ui","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":"internal/web/service/server.go","lineNumber":2380,"sourceCode":"\treturn auths\n}\n\nfunc vlessEncAuthID(label string) string {\n\tnormalized := strings.NewReplacer(\"-\", \"\", \"_\", \"\", \" \", \"\").Replace(strings.ToLower(label))\n\tswitch {\n\tcase strings.Contains(normalized, \"mlkem768\"):\n\t\treturn \"mlkem768\"\n\tcase strings.Contains(normalized, \"x25519\"):\n\t\treturn \"x25519\"\n\tdefault:\n\t\treturn normalized\n\t}\n}\n\nfunc (s *ServerService) GetNewUUID() (map[string]string, error) {\n\tnewUUID, err := uuid.NewRandom()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to generate UUID: %w\", err)\n\t}\n\n\treturn map[string]string{\n\t\t\"uuid\": newUUID.String(),\n\t}, nil\n}\n\nfunc (s *ServerService) GetNewmlkem768() (any, error) {\n\t// Run the command\n\tcmd := exec.CommandContext(context.Background(), xray.GetBinaryPath(), \"mlkem768\")\n\tvar out bytes.Buffer\n\tcmd.Stdout = &out\n\terr := cmd.Run()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tseed, client, err := parseXrayKeyPairOutput(out.String())","sourceCodeStart":2362,"sourceCodeEnd":2398,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/web/service/server.go#L2362-L2398","documentation":"Returned by ServerService.GetNewUUID when google/uuid's NewRandom() fails. NewRandom reads 16 bytes from crypto/rand, so this error almost always means the OS random source could not be read (EAGAIN on getrandom(2), a blocked entropy pool on early-boot kernels, or a fd/ulimit exhaustion in constrained containers). It is not related to UUID formatting or duplication.","triggerScenarios":"Any call to the panel endpoint that generates a new client UUID (e.g. the 'new UUID' button in the client editor) on a host where crypto/rand.Read returns an error: early-boot VM before the CRNG is seeded, a seccomp/container profile blocking getrandom, or process fd exhaustion.","commonSituations":"Small embedded/VM images booted straight into the panel, hardened container runtimes, or hosts under fd pressure. On modern kernels (5.6+) getrandom never blocks after seeding, so this is rare; older kernels can block at boot.","solutions":["Check host entropy/CRNG state: cat /proc/sys/kernel/random/entropy_info or dmesg for 'crng init done'; if not initialized, wait or add a hardware RNG (haveged is a last resort).","Inspect the panel logs for the wrapped error text — the %w chain names the syscall reason (e.g. 'resource temporarily unavailable' = fd/pressure, 'operation not permitted' = seccomp).","If running in a restricted container, allow getrandom(2) in the seccomp profile or raise the fd limit (ulimit -n) and restart the panel.","Retry the request once; transient EAGAIN on getrandom is self-healing."],"exampleFix":"// before\nnewUUID, err := uuid.NewRandom()\nif err != nil {\n    return nil, fmt.Errorf(\"failed to generate UUID: %w\", err)\n}\n\n// after (caller side, e.g. controller): keep the guard, surface a retryable hint\nnewUUID, err := uuid.NewRandom()\nif err != nil {\n    return nil, fmt.Errorf(\"failed to generate UUID (host random source unavailable, check crng/fd limits): %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"// In Go: capture and surface the wrapped syscall cause; retry once only for EAGAIN-style transients\nnewUUID, err := uuid.NewRandom()\nif err != nil {\n    if errors.Is(err, syscall.EAGAIN) {\n        time.Sleep(50 * time.Millisecond)\n        newUUID, err = uuid.NewRandom()\n    }\n    if err != nil {\n        return fmt.Errorf(\"uuid generation failed (host random source issue): %w\", err)\n    }\n}","preventionTips":["Monitor fd usage and seccomp profiles on panel hosts so crypto/rand stays available.","Alert on any occurrence — it should be near-impossible on healthy kernels and signals host-level trouble."],"tags":["crypto","entropy","uuid","server"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}