istio/istio · error

invalid level option

Error message

invalid level option

What it means

MessageThreshold implements pflag.Value for istioctl's --threshold/-l log-level flags. Set uppercases the input and looks it up in diag.GetUppercaseStringToLevelMap() (e.g. ERROR, WARNING, INFO); unknown strings return 'invalid level option'. This is strict CLI argument parsing before any command runs.

Source

Thrown at istioctl/pkg/util/formatting/msg_threshold.go:45

	diag.Level
}

// String is a function declared in the pflag.Value interface
func (m *MessageThreshold) String() string {
	return m.Level.String()
}

// Type is a function declared in the pflag.Value interface
func (m *MessageThreshold) Type() string {
	return "Level"
}

// Set is a function declared in the pflag.Value interface
func (m *MessageThreshold) Set(s string) error {
	levelMap := diag.GetUppercaseStringToLevelMap()
	level, ok := levelMap[strings.ToUpper(s)]
	if !ok {
		return errors.New("invalid level option")
	}
	m.Level = level
	return nil
}

View on GitHub (pinned to 8dc789c5cf)

Solutions

  1. Use one of the valid values printed in the flag usage / diag.GetAllLevelStrings() — typically ERROR, WARNING, INFO
  2. Check for trailing whitespace/typos in scripted flag values
  3. Run the command with -h to see the accepted list for your istioctl version

Example fix

# before
istioctl precheck -l verbose

# after
istioctl precheck -l WARNING
Defensive patterns

Strategy: validation

Validate before calling

valid := map[string]bool{"ERROR": true, "WARNING": true, "INFO": true}
level := strings.ToUpper(strings.TrimSpace(input))
if !valid[level] {
    return fmt.Errorf("invalid level %q; valid: ERROR, WARNING, INFO", input)
}

Prevention

When it happens

Trigger: Passing a level string not in the map, e.g. `istioctl analyze -l verbose`, `-l err`, `-l fatal` (if unsupported), or locale variants like 'Warn' spelled differently; anything except the documented level names.

Common situations: Muscle memory from other tools (logrus/zap levels like 'fatal', 'debug'); scripting with dynamically built flag values that are empty or misspelled; version differences in accepted level names.

Related errors


AI-assisted analysis of istio/istio@8dc789c5cf (2026-08-15). Data as JSON: /api/errors/0d2ff688c81bb0d8. Report an issue: GitHub.