caddyserver/caddy · error

plaintext is required

Error message

plaintext is required

What it means

Guard in `caddy hash-password`: after reading the plaintext password (terminal or piped stdin), its length is zero, so there is nothing to hash. The faulty input is an empty password on stdin or an empty --plaintext value.

Solutions

  1. Provide the plaintext password via --plaintext or when prompted by 'caddy hash-password'.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/caddyhttp/caddyauth/command.go:138 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/88d4a79e111473ea. Report an issue: GitHub.

Appendix: source

Thrown at modules/caddyhttp/caddyauth/command.go:138

			if err != nil {
				return caddy.ExitCodeFailedStartup, err
			}

			if !bytes.Equal(plaintext, confirmation) {
				return caddy.ExitCodeFailedStartup, fmt.Errorf("password does not match")
			}
		} else {
			rd := bufio.NewReader(os.Stdin)
			plaintext, err = rd.ReadBytes('\n')
			if err != nil {
				return caddy.ExitCodeFailedStartup, err
			}

			plaintext = plaintext[:len(plaintext)-1] // Trailing newline
		}

		if len(plaintext) == 0 {
			return caddy.ExitCodeFailedStartup, fmt.Errorf("plaintext is required")
		}
	}

	var hash []byte
	var hashString string
	switch algorithm {
	case bcryptName:
		hash, err = BcryptHash{cost: bcryptCost}.Hash(plaintext)
		hashString = string(hash)
	case argon2idName:
		time, err := fs.GetUint32("argon2id-time")
		if err != nil {
			return caddy.ExitCodeFailedStartup, fmt.Errorf("failed to get argon2id time parameter: %w", err)
		}
		memory, err := fs.GetUint32("argon2id-memory")
		if err != nil {
			return caddy.ExitCodeFailedStartup, fmt.Errorf("failed to get argon2id memory parameter: %w", err)
		}

View on GitHub (pinned to 50e54ee279)