kubernetes/kops · error

unknown output format: %q

Error message

unknown output format: %q

What it means

`kops get sshpublickeys` accepts only table, yaml, and json for --output. Any other value falls through the switch to the default branch, returning "unknown output format: %q" with the offending string. Pure flag validation.

Source

Thrown at cmd/kops/get_sshpublickeys.go:137

	case OutputYaml:
		y, err := yaml.Marshal(items)
		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(items)
		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("unknown output format: %q", options.Output)
	}

	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run `kops get sshpublickeys --help` and pick a supported value: table, yaml, or json
  2. Fix the typo or interpolate the correct value in your script
  3. Add a validation step in scripts: case "$FMT" in table|json|yaml) ;; *) exit 1;; esac

Example fix

// before
kops get sshpublickeys -o $FORMAT   # FORMAT="csv"
// after
FMT=json
kops get sshpublickeys -o $FMT      # or validate FMT against table|json|yaml first
Defensive patterns

Strategy: validation

Validate before calling

case "$OUT" in
  table|json|yaml) ;;
  *) echo "invalid -o '$OUT' for sshpublickeys; expected table|json|yaml"; exit 1 ;;
esac
kops get sshpublickeys -o "$OUT"

Prevention

When it happens

Trigger: `kops get sshpublickeys -o csv`, `-o table` misspelled (e.g. `-o tabel`), or scripts interpolating an unvalidated format variable into --output.

Common situations: Typos in shell scripts; reusing flag values from other tools (e.g. `-o wide`); empty variable expansion leaving `-o ""`.

Related errors


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