{"record":{"id":"6dec2b8e5f0344b9","repo":"amir20/dozzle","slug":"password-is-required","errorCode":null,"errorMessage":"password is required","messagePattern":"password is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/cli/generate_command.go","lineNumber":41,"sourceCode":"}\n\nfunc (g *GenerateCmd) Run(args Args, embeddedCerts embed.FS) error {\n\twriter := zerolog.NewConsoleWriter()\n\tlog.Logger = log.Output(writer)\n\tStartEvent(args, \"\", nil, \"generate\")\n\tif args.Generate.Username == \"\" {\n\t\treturn fmt.Errorf(\"username is required\")\n\t}\n\n\tpassword := args.Generate.Password\n\tif password == \"\" {\n\t\tvar err error\n\t\tif password, err = readPassword(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif password == \"\" {\n\t\treturn fmt.Errorf(\"password is required\")\n\t}\n\n\tbuffer := auth.GenerateUsers(auth.User{\n\t\tUsername:        args.Generate.Username,\n\t\tPassword:        password,\n\t\tName:            args.Generate.Name,\n\t\tEmail:           args.Generate.Email,\n\t\tFilter:          args.Generate.Filter,\n\t\tRolesConfigured: args.Generate.RolesConfigured,\n\t}, true)\n\n\tif _, err := os.Stdout.Write(buffer.Bytes()); err != nil {\n\t\treturn fmt.Errorf(\"failed to write to stdout: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/cli/generate_command.go#L23-L59","documentation":"The `dozzle generate` command produces a users.yml config block. After optionally prompting for a password, if the password is still empty the command refuses to generate users with an empty credential and returns this error instead of writing an invalid user entry.","triggerScenarios":"Running `dozzle generate` when stdin is a terminal but the user submits an empty password, or when stdin is piped/redirected and contains only whitespace/newlines, so readPassword() trims it to \"\".","commonSituations":"CI scripts piping an empty or missing password variable (`echo \"$EMPTY_VAR\" | dozzle generate`); users pressing Enter at the Password prompt; scripted setups where the env var holding the password is unset.","solutions":["Provide a non-empty password: pipe it in (`echo 'mypassword' | dozzle generate`) or type it at the prompt","Check that the environment variable feeding the pipe is actually set before invoking the command","If non-interactive, ensure stdin contains at least one non-empty line"],"exampleFix":"// before\nunset PASSWORD\necho \"$PASSWORD\" | dozzle generate\n// after\nexport PASSWORD=mypassword\necho \"$PASSWORD\" | dozzle generate","handlingStrategy":"validation","validationCode":"if [ -z \"$PASSWORD\" ]; then echo 'PASSWORD is empty' >&2; exit 1; fi\necho \"$PASSWORD\" | dozzle generate","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set and check the password variable before piping to dozzle generate","Test the generate command with the same stdin setup used in CI"],"tags":["cli","authentication","validation"],"backgroundTag":"empty-required-field","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}