kubernetes/kops · error

unknown output format: %q

Error message

unknown output format: %q

What it means

RunGetAll validates options.Output against the known formats (table, yaml, json) and returns this error for anything else in its default branch. Unlike get_assets, it does not restrict registration of the --output flag values, so an arbitrary value can reach this switch.

Source

Thrown at cmd/kops/get_all.go:160

		err = clusterOutputTable([]*api.Cluster{cluster}, out)
		if err != nil {
			return err
		}
		fmt.Fprintf(out, "\nInstance Groups\n")
		err = igOutputTable(cluster, instancegroups, out)
		if err != nil {
			return err
		}
		if len(addonObjects) != 0 {
			fmt.Fprintf(out, "\nAddon Objects\n")
			err = addonsOutputTable(cluster, addonObjects, out)
			if err != nil {
				return err
			}
		}

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

	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use only table, yaml, or json for -o/--output
  2. For machine-readable output use -o yaml or -o json and post-process with yq/jq
  3. Check the value passed by scripts/aliases for typos or empty strings

Example fix

// before
kops get all mycluster.example.com -o jsonpath='{.items[*].metadata.name}'
// after
kops get all mycluster.example.com -o json | jq -r '.items[].metadata.name'
Defensive patterns

Strategy: validation

Validate before calling

func validateOutput(o string) error {
    switch o {
    case "table", "yaml", "json":
        return nil
    default:
        return fmt.Errorf("unknown output format %q; use table, yaml or json", o)
    }
}
// call before RunGetAll
if err := validateOutput(options.Output); err != nil { return err }

Type guard

func validOutput(o string) bool {
    return o == "table" || o == "yaml" || o == "json"
}

Try / catch

err := RunGetAll(ctx, f, out, options)
if err != nil && strings.HasPrefix(err.Error(), "unknown output format") {
    fmt.Fprintln(os.Stderr, "tip: only table, yaml, json are supported")
}

Prevention

When it happens

Trigger: `kops get all <cluster> -o <anything-other-than-table|yaml|json>`, e.g. `-o jsonpath=...` or `-o wide`, which kops get does not support; or a scripted value that is empty or misformatted.

Common situations: Copy-pasted kubectl invocations using jsonpath/wide/custom-columns output that kops does not implement; automation passing an empty or wrongly spelled -o value; mixed-version scripts built against a different tool's flags.

Related errors


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