hashicorp/packer · error

expected one of %q

Error message

expected one of %q

What it means

CLI flag parsing error from enumFlag.Set: the value passed to a one-of-a-set flag (e.g. a log level or format selector) does not match any of the allowed options enumerated in the error. Returned when Set fails to find the value among f.options.

Source

Thrown at command/enumflag/flag.go:30

// New returns a flag.Value implementation for parsing flags with a one-of-a-set value
func New(target *string, options ...string) *enumFlag {
	return &enumFlag{target: target, options: options}
}

func (f *enumFlag) String() string {
	return *f.target
}

func (f *enumFlag) Set(value string) error {
	for _, v := range f.options {
		if v == value {
			*f.target = value
			return nil
		}
	}

	return fmt.Errorf("expected one of %q", f.options)
}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Re-run the command with one of the values listed in %q, e.g. the exact allowed flag values
  2. Check the command's help output for the flag's accepted values
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at command/enumflag/flag.go:30 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/c2a0a6b923743944. Report an issue: GitHub.