{"record":{"id":"d835773c5785f9df","repo":"wavetermdev/waveterm","slug":"error-generating-random-string-w","errorCode":null,"errorMessage":"error generating random string: %w","messagePattern":"error generating random string: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/conncontroller/conncontroller.go","lineNumber":281,"sourceCode":"}\n\nfunc (conn *SSHConn) GetName() string {\n\t// no lock required because opts is immutable\n\treturn conn.Opts.String()\n}\n\nfunc (conn *SSHConn) OpenDomainSocketListener(ctx context.Context) error {\n\tconn.Infof(ctx, \"running OpenDomainSocketListener...\\n\")\n\tallowed := WithLockRtn(conn, func() bool {\n\t\treturn conn.Status == Status_Connecting\n\t})\n\tif !allowed {\n\t\treturn fmt.Errorf(\"cannot open domain socket for %q when status is %q\", conn.GetName(), conn.GetStatus())\n\t}\n\tclient := conn.GetClient()\n\trandStr, err := utilfn.RandomHexString(16) // 64-bits of randomness\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error generating random string: %w\", err)\n\t}\n\tsockName := fmt.Sprintf(\"/tmp/waveterm-%s.sock\", randStr)\n\tconn.Infof(ctx, \"generated domain socket name %s\\n\", sockName)\n\tlistener, err := client.ListenUnix(sockName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to request connection domain socket: %v\", err)\n\t}\n\tconn.WithLock(func() {\n\t\tconn.DomainSockName = sockName\n\t\tconn.DomainSockListener = listener\n\t})\n\tconn.Infof(ctx, \"successfully connected domain socket\\n\")\n\tgo func() {\n\t\tdefer func() {\n\t\t\tpanichandler.PanicHandler(\"conncontroller:OpenDomainSocketListener\", recover())\n\t\t}()\n\t\tdefer conn.WithLock(func() {\n\t\t\tconn.DomainSockListener = nil","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/conncontroller/conncontroller.go#L263-L299","documentation":"The listener derives a random socket name from 16 random bytes via utilfn.RandomHexString. If the platform CSPRNG fails, the error is wrapped as 'error generating random string'. This is extremely rare and almost always indicates an OS-level entropy/crypto failure.","triggerScenarios":"utilfn.RandomHexString(16) returns an error during OpenDomainSocketListener, e.g. crypto/rand read failure on the local machine.","commonSituations":"Depleted or broken /dev/urandom, sandboxed environments restricting crypto/rand, severe OS resource exhaustion.","solutions":["Inspect the wrapped underlying error to identify the OS-level RNG failure","Check that /dev/urandom (or the platform equivalent) is readable in the environment","Retry after fixing the environment; the failure is transient in virtually all cases"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := conn.OpenDomainSocketListener(ctx)\nif err != nil {\n    var genErr *fmt.wrapError\n    if errors.As(err, &genErr) && strings.Contains(err.Error(), \"error generating random string\") {\n        // OS RNG failure: log, fix environment, retry later\n    }\n}","preventionTips":["Ensure /dev/urandom is available in containers/sandboxes","Treat this as an OS-level red flag; investigate the environment, not the library","Add alerting if it recurs — it should essentially never happen"],"tags":["crypto","random","environment"],"backgroundTag":"random-generation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}