AdguardTeam/AdGuardHome · error

generating password hash: %w

Error message

generating password hash: %w

What it means

During migration to schema 5, bcrypt failed to hash the legacy plaintext auth_pass so it could be moved into the users structure. The bcrypt error is wrapped; with a valid password string this is essentially unreachable, since bcrypt only fails on inputs longer than 72 bytes or cost out of range.

Source

Thrown at internal/configmigrate/v5.go:41

//	# …
func (m *Migrator) migrateTo5(_ context.Context, diskConf yobj) (err error) {
	diskConf["schema_version"] = 5

	user := yobj{}

	if err = moveVal[string](diskConf, user, "auth_name", "name"); err != nil {
		return err
	}

	pass, ok, err := fieldVal[string](diskConf, "auth_pass")
	if !ok {
		return err
	}
	delete(diskConf, "auth_pass")

	hash, err := bcrypt.GenerateFromPassword([]byte(pass), bcrypt.DefaultCost)
	if err != nil {
		return fmt.Errorf("generating password hash: %w", err)
	}

	user["password"] = string(hash)
	diskConf["users"] = yarr{user}

	return nil
}

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Shorten the legacy auth_pass to ≤ 72 characters and re-run the migration
  2. If the password is already hashed or unused, remove auth_pass before migrating
  3. Upgrade to a newer config schema or regenerate the config and set the password via the UI

Example fix

# before
auth_pass: "an extremely long legacy password exceeding seventy two bytes ..."

# after
auth_pass: "shorter-legacy-password"
Defensive patterns

Strategy: validation

Validate before calling

if len(pass) > 72 { /* truncate or shorten the legacy auth_pass before migrating */ }

Try / catch

if err != nil && strings.Contains(err.Error(), "generating password hash") { /* shorten auth_pass to ≤72 bytes and re-run Migrate */ }

Prevention

When it happens

Trigger: Migrating a very old config whose auth_pass exceeds 72 bytes (bcrypt's input limit) or a bcrypt cost issue with DefaultCost on constrained platforms.

Common situations: Ancient configs with extremely long passwords; FIPS-restricted or limited environments where bcrypt primitives are unavailable.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/0930eb91fd610b73. Report an issue: GitHub.