amir20/dozzle · error

username is required

Error message

username is required

What it means

Returned by GenerateCmd.Run when args.Generate.Username is empty. The generate command creates a user entry (for users.yml auth), and a username is mandatory, so it fails fast before prompting for a password.

Solutions

  1. Pass a username: `dozzle generate --name "Admin" admin` (username is the positional arg).
  2. Check the command help: `dozzle generate --help` for the expected argument order.
  3. Fix automation scripts to interpolate a non-empty username variable.
  4. If the username was meant to come from env/config, export and pass it explicitly.

Example fix

// before
./dozzle generate --password secret123
// after
./dozzle generate --password secret123 admin
Defensive patterns

Strategy: validation

Validate before calling

[ -n "$USERNAME" ] || { echo 'username is required'; exit 1; }

Try / catch

if err := generateCmd.Run(args, embeddedCerts); err != nil {
  if strings.Contains(err.Error(), "username is required") {
    log.Fatal().Msg("pass a positional username, e.g. dozzle generate admin")
  }
}

Prevention

When it happens

Trigger: Running `dozzle generate` without the positional username argument; passing an empty string via automation; invoking the command with flags only and no positional value.

Common situations: Scripting user generation and forgetting the positional argument; interactive users pressing enter at the wrong prompt; copy-pasting an example command and dropping the username token.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07). Data as JSON: /api/errors/f82757aae5be4377. Report an issue: GitHub.

Appendix: source

Thrown at internal/support/cli/generate_command.go:30

	"github.com/rs/zerolog/log"
	"golang.org/x/term"
)

type GenerateCmd struct {
	Username        string `arg:"positional"`
	Password        string `arg:"--password, -p" help:"sets the password for the user"`
	Name            string `arg:"--name, -n" help:"sets the display name for the user"`
	Email           string `arg:"--email, -e" help:"sets the email for the user"`
	Filter          string `arg:"--user-filter" help:"sets the filter for the user. This can be a comma separated list of filters."`
	RolesConfigured string `arg:"--user-roles" help:"sets the roles for the user. This can be a comma separated list of roles."`
}

func (g *GenerateCmd) Run(args Args, embeddedCerts embed.FS) error {
	writer := zerolog.NewConsoleWriter()
	log.Logger = log.Output(writer)
	StartEvent(args, "", nil, "generate")
	if args.Generate.Username == "" {
		return fmt.Errorf("username is required")
	}

	password := args.Generate.Password
	if password == "" {
		var err error
		if password, err = readPassword(); err != nil {
			return err
		}
	}
	if password == "" {
		return fmt.Errorf("password is required")
	}

	buffer := auth.GenerateUsers(auth.User{
		Username:        args.Generate.Username,
		Password:        password,
		Name:            args.Generate.Name,
		Email:           args.Generate.Email,

View on GitHub (pinned to d9463cbe21)