derailed/k9s · error

default value %q for input %q is not a valid option

Error message

default value %q for input %q is not a valid option

What it means

Returned by Plugin.Validate (internal/config/plugin.go:98) when a dropdown-typed input declares a default value that is not a member of its options list. The dropdown UI can only offer listed options, so a default outside the list has no valid selection. As with all Plugin.Validate failures, the containing plugin file is rejected at load time ('plugin validation failed for ...') and the plugin is not registered.

Source

Thrown at internal/config/plugin.go:98

}

// Validate checks the plugin configuration for errors.
func (p *Plugin) Validate() error {
	seen := make(map[string]struct{}, len(p.Inputs))
	for _, input := range p.Inputs {
		if _, ok := seen[input.Name]; ok {
			return fmt.Errorf("duplicate input name %q", input.Name)
		}
		seen[input.Name] = struct{}{}

		if input.Default == "" {
			continue
		}

		switch input.Type {
		case InputTypeDropdown:
			if !slices.Contains(input.Options, input.Default) {
				return fmt.Errorf("default value %q for input %q is not a valid option", input.Default, input.Name)
			}
		case InputTypeBool:
			if input.Default != "true" && input.Default != "false" {
				return fmt.Errorf("default value %q for bool input %q must be \"true\" or \"false\"", input.Default, input.Name)
			}
		case InputTypeNumber:
			if _, err := strconv.ParseFloat(input.Default, 64); err != nil {
				return fmt.Errorf("default value %q for number input %q is not a valid number", input.Default, input.Name)
			}
		}
	}

	return nil
}

// NewPlugins returns a new plugin.
func NewPlugins() Plugins {
	return Plugins{

View on GitHub (pinned to 2d3ccc6ba2)

Solutions

  1. Add the intended default to the options list
  2. Or change default to one of the existing options (exact string match, case-sensitive)
  3. Or remove the default entirely — empty default skips validation and prompts without preselection

Example fix

# before
inputs:
  - name: env
    type: dropdown
    options: [dev, staging]
    default: prod

# after (option A: add it)
    options: [dev, staging, prod]
    default: prod
# after (option B: pick existing)
    options: [dev, staging]
    default: staging
Defensive patterns

Strategy: validation

Validate before calling

func dropdownDefaultValid(p Plugin) error {
	for _, in := range p.Inputs {
		if in.Type == InputTypeDropdown && in.Default != "" &&
			!slices.Contains(in.Options, in.Default) {
			return fmt.Errorf("input %s: default %q not in options", in.Name, in.Default)
		}
	}
	return nil
}

Prevention

When it happens

Trigger: inputs: [{name: env, type: dropdown, options: [dev, staging], default: prod}] — 'prod' is not among the options; also triggered by case/whitespace mismatches ('Dev' vs 'dev') or when options are reordered/renamed and the default was forgotten.

Common situations: Editing an existing dropdown's option list without updating default; copy-pasting between plugin definitions; YAML quoting differences ('true' vs true) changing string comparison.

Related errors


AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15). Data as JSON: /api/errors/2ae31187f00542bb. Report an issue: GitHub.