kubernetes/kops · error

unsupported output type %q

Error message

unsupported output type %q

What it means

After creating the InstanceGroup, RunCreateInstanceGroup switches on options.Output to decide how to print the result. Only yaml and json are supported; any other value reaches the default branch and returns this error. It is a guard against invalid user-supplied output format flags.

Source

Thrown at cmd/kops/create_instancegroup.go:252

		}

		// Cluster name is not populated, and we need it
		ig.ObjectMeta.Labels = make(map[string]string)
		ig.ObjectMeta.Labels[kopsapi.LabelClusterName] = cluster.ObjectMeta.Name

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

	if options.Edit {
		edit := editor.NewDefaultEditor(commandutils.EditorEnvs)

		raw, err := kopscodecs.ToVersionedYaml(ig)
		if err != nil {
			return err
		}
		ext := "yaml"

		// launch the editor
		edited, file, err := edit.LaunchTempFile(fmt.Sprintf("%s-edit-", filepath.Base(os.Args[0])), ext, bytes.NewReader(raw))
		defer func() {
			if file != "" {
				try.RemoveFile(file)
			}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use `-o yaml` or `-o json` explicitly
  2. Check the command help (`kops create instancegroup --help`) for supported output values
  3. Fix typos in the --output flag value (e.g. 'ymal' -> 'yaml')
  4. Ensure any script variable feeding --output is set and equals 'yaml' or 'json'

Example fix

// before
kops create instancegroup --name nodes --output table
// after
kops create instancegroup --name nodes --output yaml
Defensive patterns

Strategy: validation

Validate before calling

if [ "$OUTPUT" != "yaml" ] && [ "$OUTPUT" != "json" ]; then echo "-o must be yaml|json" >&2; exit 2; fi

Type guard

func validOutput(s string) bool { switch s { case "yaml", "json": return true }; return false }

Prevention

When it happens

Trigger: Invoking `kops create instancegroup --output <format>` (or -o) with any value other than "yaml" or "json", e.g. `--output table`, `--output yamlv2`, or a typo like `--output ymal`.

Common situations: Copy-pasted commands from other k8s CLIs that accept other formats; scripting with a variable that is empty or misspelled; assuming output formats supported by other kops subcommands apply here.

Related errors


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