kubernetes/kops · error

unknown output format: %q

Error message

unknown output format: %q

What it means

`kops get secrets` only supports a fixed set of --output values (table, text/yaml, json, depending on implementation). When options.Output holds any other string, the switch's default branch returns "unknown output format: %q". It is pure input validation of the -o/--output flag.

Source

Thrown at cmd/kops/get_secrets.go:168

			var data string
			secret, err := secretStore.FindSecret(item)
			if err != nil {
				return fmt.Errorf("getting secret %q: %v", item, err)
			}
			if secret == nil {
				return fmt.Errorf("cannot find secret %q", item)
			}
			data = string(secret.Data)

			_, err = fmt.Fprintf(out, "%s\n", data)
			if err != nil {
				return fmt.Errorf("writing output: %v", err)
			}
		}
		return nil

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

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run `kops get secrets --help` and use exactly one of the supported values (table/text, json, yaml as listed)
  2. Correct the flag, e.g. `-o json` instead of `-o xml`
  3. Quote/validate the variable supplying --output in scripts before invoking kops

Example fix

// before
kops get secrets mysecret -o xml
// after
kops get secrets mysecret -o json
Defensive patterns

Strategy: validation

Validate before calling

case "$OUT" in
  table|text|json|yaml) ;;
  *) echo "unsupported --output '$OUT'; use table, text, json, yaml"; exit 1 ;;
esac
kops get secrets -o "$OUT"

Prevention

When it happens

Trigger: Invoking `kops get secrets --output xml`, `--output yaml` when only table/json are accepted, or passing an empty/garbled value via scripts or wrappers that set the flag programmatically.

Common situations: Typos in the flag value; copying examples from other k8s tools with different output names; CI scripts parameterizing the output format with an unvalidated variable.

Related errors


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