kubernetes/kops · error

unsupported output format: %q

Error message

unsupported output format: %q

What it means

RunGetAssets validates options.Output against table, yaml, and json and returns this error from the default branch for any other value. Note the differing message text ('unsupported output format' vs get_all's 'unknown output format') but the same behavior.

Source

Thrown at cmd/kops/get_assets.go:175

		return fileOutputTable(result.Files, out)
	case OutputYaml:
		y, err := yaml.Marshal(result)
		if err != nil {
			return fmt.Errorf("unable to marshal YAML: %v", err)
		}
		if _, err := out.Write(y); err != nil {
			return fmt.Errorf("error writing to output: %v", err)
		}
	case OutputJSON:
		j, err := json.Marshal(result)
		if err != nil {
			return fmt.Errorf("unable to marshal JSON: %v", err)
		}
		if _, err := out.Write(j); err != nil {
			return fmt.Errorf("error writing to output: %v", err)
		}
	default:
		return fmt.Errorf("unsupported output format: %q", options.Output)
	}

	return nil
}

func imageOutputTable(images []*Image, out io.Writer) error {
	fmt.Println("")
	t := &tables.Table{}
	t.AddColumn("CANONICAL", func(i *Image) string {
		return i.Canonical
	})
	t.AddColumn("DOWNLOAD", func(i *Image) string {
		return i.Download
	})

	columns := []string{"CANONICAL", "DOWNLOAD"}
	return t.Render(images, out, columns...)
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use -o table (default), -o yaml, or -o json
  2. Mind case: values must be lowercase yaml/json/table
  3. Fix scripts/aliases to pass only supported values

Example fix

// before
kops get assets -o Yaml
// after
kops get assets -o yaml
Defensive patterns

Strategy: validation

Validate before calling

func validAssetsOutput(o string) bool {
    switch o {
    case "table", "yaml", "json":
        return true
    }
    return false
}
// before RunGetAssets
if !validAssetsOutput(options.Output) {
    return fmt.Errorf("unsupported output format %q; use table, yaml or json", options.Output)
}

Type guard

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

Try / catch

err := RunGetAssets(ctx, f, out, options)
if err != nil && strings.Contains(err.Error(), "unsupported output format") {
    fmt.Fprintln(os.Stderr, "supported: -o table|yaml|json")
}

Prevention

When it happens

Trigger: `kops get assets -o <invalid>`, e.g. -o wide, jsonpath, empty string, or a scripted value that isn't one of the three supported formats.

Common situations: Habitual kubectl flags like jsonpath/custom-columns applied to kops; automation templates passing wrong -o values; typos such as -o Yaml (case-sensitive).

Related errors


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