kubernetes/kops · error

unsupported output format: %q

Error message

unsupported output format: %q

What it means

toolbox dump accepts only the registered output formats (yaml, json; default text/table). If options.Output holds any other string, the switch hits the default branch and returns this error before any dump work is output.

Source

Thrown at cmd/kops/toolbox_dump.go:321

			_, err = out.Write(b)
			if err != nil {
				return fmt.Errorf("error writing to stdout: %v", err)
			}
			return nil

		case OutputJSON:
			b, err := json.MarshalIndent(cloudResources, "", "  ")
			if err != nil {
				return fmt.Errorf("error marshaling json: %v", err)
			}
			_, err = out.Write(b)
			if err != nil {
				return fmt.Errorf("error writing to stdout: %v", err)
			}
			return nil

		default:
			return fmt.Errorf("unsupported output format: %q", options.Output)
		}
	}
	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use -o yaml or -o json exactly (lowercase)
  2. Omit -o to get the default human-readable output
  3. Check `kops toolbox dump --help` for supported values

Example fix

// before
kops toolbox dump -o yml > dump.yaml
// after
kops toolbox dump -o yaml > dump.yaml
Defensive patterns

Strategy: validation

Validate before calling

case "$OUTPUT" in
  yaml|json|"") ;;
  *) echo "unsupported output format: $OUTPUT (use yaml or json)" >&2; exit 2 ;;
esac
kops toolbox dump -o "$OUTPUT"

Prevention

When it happens

Trigger: Running `kops toolbox dump -o <bad-value>` where <bad-value> is anything other than yaml/json (e.g. `yml`, `YAML` uppercase, `table`).

Common situations: Typo in the -o/--output flag; copy-pasting `yml` from documentation; scripts written against a different tool's accepted formats.

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/599ee2e135f4e689. Report an issue: GitHub.