kubernetes/kops · error

unsupported output type %q

Error message

unsupported output type %q

What it means

In --dry-run mode, options.Output matched neither the YAML nor JSON constants, so kOps refuses to emit the InstanceGroups rather than guessing a format. This is a strict validation of the --output flag value.

Source

Thrown at cmd/kops/toolbox_instance-selector.go:338

		if igCount != 1 {
			doubledRatio := (*mutatedFilters.VCpusToMemoryRatio) * 2
			mutatedFilters.VCpusToMemoryRatio = &doubledRatio
		}
	}

	if options.DryRun {
		for _, ig := range newInstanceGroups {
			switch options.Output {
			case OutputYaml:
				if err := fullOutputYAML(out, ig); err != nil {
					return fmt.Errorf("error writing cluster yaml to stdout: %v", err)
				}
			case OutputJSON:
				if err := fullOutputJSON(out, true, ig); err != nil {
					return fmt.Errorf("error writing cluster json to stdout: %v", err)
				}
			default:
				return fmt.Errorf("unsupported output type %q", options.Output)
			}
		}
		return nil
	}

	for _, ig := range newInstanceGroups {
		_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{})
		if err != nil {
			return fmt.Errorf("error storing InstanceGroup: %v", err)
		}

		if err := fullOutputYAML(out, ig); err != nil {
			return fmt.Errorf("error writing cluster yaml to stdout: %v", err)
		}
	}

	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Pass --output yaml or --output json exactly (lowercase).
  2. Omit conflicting formats when scripting; validate the flag in wrapper scripts.
  3. Check `kops toolbox instance-selector --help` for accepted values.

Example fix

// before
kops toolbox instance-selector --dry-run --output yml
// after
kops toolbox instance-selector --dry-run --output yaml
Defensive patterns

Strategy: validation

Validate before calling

func validOutput(o string) bool { return o == "yaml" || o == "json" }
// usage: if !validOutput(*outputFlag) { flag.Usage(); os.Exit(2) }

Prevention

When it happens

Trigger: Running `kops toolbox instance-selector --dry-run` with --output set to something other than yaml/json (e.g. 'yml', 'text', or a misspelling) — the switch in the dry-run branch falls through to default.

Common situations: Typo like --output YML (case-sensitive constants) or abbreviations; scripts copied from `kops get` examples using formats supported elsewhere but not here.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/5f31abf94d65f4fd. Report an issue: GitHub.