{"record":{"id":"9a62cdb148ee9f66","repo":"lima-vm/lima","slug":"failed-to-generate-password-w","errorCode":null,"errorMessage":"failed to generate password: %w","messagePattern":"failed to generate password: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cidata/template.go","lineNumber":147,"sourceCode":"\tSkipDefaultDependencyResolution bool\n\tVMType                          string\n\tVSockPort                       int\n\tVirtioPort                      string\n\tPlain                           bool\n\tTimeZone                        string\n\tNoCloudInit                     bool\n\tWindowsInitialPassword          string\n\tLegacyBIOS                      bool\n\tIsWindowsServer                 bool\n\tTPM                             bool\n}\n\nfunc (t *TemplateArgs) generateWindowsInitialPassword() error {\n\tconst pwLen = 16\n\t// Avoid special characters to minimize potential keyboard layout issue.\n\tpw, err := password.Generate(pwLen, pwLen/4, 0, false, false)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to generate password: %w\", err)\n\t}\n\n\tt.WindowsInitialPassword = pw\n\treturn nil\n}\n\n// checkWindowsVersion checks if a guest VM is Windows 11 (true) or Windows server 2025 (false).\nfunc (t *TemplateArgs) checkWindowsVersion(instDir string) error {\n\timagePath := filepath.Join(instDir, filenames.ISO)\n\tlabel, err := iso9660util.Label(imagePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get ISO label: %w\", err)\n\t}\n\n\tt.IsWindowsServer = !strings.HasPrefix(label, windowsClientISOLabelPrefix)\n\n\treturn nil\n}","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/cidata/template.go#L129-L165","documentation":"generateWindowsInitialPassword (pkg/cidata/template.go:147) generates the initial Windows guest admin password using password.Generate(16, 4, 0, false, false). If the generator returns an error (e.g. requested digit count cannot be satisfied for the length/constraints), it is wrapped with this message and Windows ISO generation aborts.","triggerScenarios":"password.Generate failing with pwLen=16 and 4 digits - practically rare; occurs on RNG/source failure or if the password library's constraints are unsatisfiable (bad parameters or entropy exhaustion).","commonSituations":"Extremely uncommon in practice; seen if system entropy source fails or the password library parameters are changed to inconsistent values in a fork/custom build.","solutions":["Simply retry the command; generation is usually transient-failure-proof","If reproducible, verify the host's random source (/dev/urandom) works","Check for a modified/forked password.Generate with incompatible parameters"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := limactl.Start(ctx, instName)\nif err != nil && strings.Contains(err.Error(), \"failed to generate password\") {\n    // transient - retry the start operation\n    return retryStart(ctx, instName)\n}","preventionTips":["This is practically never hit with stock parameters; treat any occurrence as an environment problem","Verify /dev/urandom availability and permissions on the host","If forking, keep password.Generate parameters consistent (len >= digits)"],"tags":["windows","password","crypto"],"backgroundTag":"password-generation-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}