cloudflare/cloudflared · error
Unknown output format '%s'
Error message
Unknown output format '%s'
What it means
renderOutput serializes command results to stdout in the format chosen by the --output flag. Only 'json' and 'yaml' are supported; any other value produces 'Unknown output format %s'. This is used by create, list, info, routes, and vnet list commands.
Source
Thrown at cmd/cloudflared/tunnel/subcommands.go:712
tunnelIDs, err := sc.findIDs(c.Args().Slice())
if err != nil {
return err
}
return sc.delete(tunnelIDs)
}
func renderOutput(format string, v interface{}) error {
switch format {
case "json":
encoder := json.NewEncoder(os.Stdout)
encoder.SetIndent("", " ")
return encoder.Encode(v)
case "yaml":
return yaml.NewEncoder(os.Stdout).Encode(v)
default:
return errors.Errorf("Unknown output format '%s'", format)
}
}
func buildRunCommand() *cli.Command {
//nolint: prealloc
cliFlags := []cli.Flag{
credentialsFileFlag,
credentialsContentsFlag,
postQuantumFlag,
selectProtocolFlag,
featuresFlag,
tunnelTokenFlag,
tunnelTokenFileFlag,
icmpv4SrcFlag,
icmpv6SrcFlag,
maxActiveFlowsFlag,
dnsResolverAddrsFlag,
}View on GitHub (pinned to 2253eeeb25)
Solutions
- Use --output json or --output yaml only (lowercase)
- Omit the --output flag entirely for the default human-readable output
- Check `cloudflared tunnel list --help` for the exact accepted values on your version
- Fix case in scripts — the format string is matched exactly
Example fix
// before cloudflared tunnel list --output table // after cloudflared tunnel list --output json # or omit --output
Defensive patterns
Strategy: validation
Validate before calling
var supportedFormats = map[string]bool{"json": true, "yaml": true}
if format != "" && !supportedFormats[strings.ToLower(format)] {
return fmt.Errorf("unsupported --output %q; use json or yaml", format)
} Type guard
func isSupportedOutputFormat(f string) bool {
return f == "" || f == "json" || f == "yaml"
} Try / catch
if err := renderOutput(format, v); err != nil {
if strings.HasPrefix(err.Error(), "Unknown output format") {
// fall back to default text output
}
return err
} Prevention
- Only use --output json or --output yaml (lowercase)
- Omit --output for human-readable output
- Pin cloudflared versions and verify flag help in CI before scripted use
- Avoid case changes — format matching is exact
When it happens
Trigger: Passing an unsupported --output value, e.g. `cloudflared tunnel list --output table`, --output JSON (case-sensitive), or --output xml.
Common situations: Users assuming table/text output is supported; capitalization mistakes like JSON/YAML; older cloudflared versions where --output handling or supported formats differ; scripts carrying flags over from other CLIs.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Couldn't parse UUID from %s
- %s is not a valid tunnel ID
- not a valid host
- no input provided
- failed to parse Host
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/40edd31a344ac091.
Report an issue: GitHub.