{"record":{"id":"ed2e9bf9a96891d4","repo":"remotion-dev/remotion","slug":"could-not-generate-random-hash-w","errorCode":null,"errorMessage":"could not generate random hash: %w","messagePattern":"could not generate random hash: %w","errorType":"exception","errorClass":"error","httpStatus":null,"severity":"error","filePath":"packages/lambda-go/s3.go","lineNumber":44,"sourceCode":"\ntype objectUploader interface {\n\tPutObject(context.Context, *s3.PutObjectInput, ...func(*s3.Options)) (*s3.PutObjectOutput, error)\n}\n\n// hashPayload returns the SHA256 hex digest used as the input-props object name.\nfunc hashPayload(payload string) string {\n\tsum := sha256.Sum256([]byte(payload))\n\treturn hex.EncodeToString(sum[:])\n}\n\n// randomHash returns a 10 character [a-z0-9] string used as a bucket suffix.\nfunc randomHash() (string, error) {\n\tconst alphabet = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n\tb := make([]byte, 10)\n\tfor i := range b {\n\t\tindex, err := rand.Int(rand.Reader, big.NewInt(int64(len(alphabet))))\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"could not generate random hash: %w\", err)\n\t\t}\n\t\tb[i] = alphabet[index.Int64()]\n\t}\n\treturn string(b), nil\n}\n\n// makeBucketName mirrors the JS SDK bucket naming convention.\nfunc makeBucketName(region string) (string, error) {\n\tsuffix, err := randomHash()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn bucketNamePrefix + strings.ReplaceAll(region, \"-\", \"\") + \"-\" + suffix, nil\n}\n\nfunc inputPropsKey(hash string) string {\n\treturn fmt.Sprintf(\"input-props/%s.json\", hash)\n}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-go/s3.go#L26-L62","documentation":"Returned by randomHash when crypto/rand.Reader fails to produce a secure random integer. The hash is used as the 10-character suffix of a new S3 bucket name. The crypto/rand source essentially never fails on a healthy Linux/macOS system, so this error almost always indicates the kernel's entropy pool is unavailable (very early boot) or that the OS random device is broken.","triggerScenarios":"rand.Int returns an error because /dev/urandom cannot be read, or the kernel CSPRNG is in a not-yet-initialized state during early boot on a VM/container without getrandom() support.","commonSituations":"Running the Go binary during container startup before the host's CRNG is initialized. Stripped-down containers that do not mount /dev/urandom. Extremely rare on modern kernels.","solutions":["Retry the operation once the host is past early boot; the CRNG initializes quickly.","Ensure /dev/urandom is mounted and readable inside the container (`ls -l /dev/urandom`).","If it persists, report a host/VM issue to your infrastructure team — this is not an application bug."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var name string\n// crypto/rand failures are transient on a cold host; one retry is reasonable.\nfor attempt := 0; attempt < 2; attempt++ {\n    n, err := randomHash()\n    if err == nil { name = n; break }\n    if attempt == 1 { return err }\n}","preventionTips":["Do not run the bucket-creation path during container early boot; let the host CRNG initialize.","Ensure /dev/urandom is mounted in stripped-down containers.","Treat a persistent crypto/rand failure as a host problem, not an app bug."],"tags":["random","crypto","entropy","s3","go","lambda-go"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}