langgenius/dify · error · OutputFormatNotSupportedError
output format not supported
Error message
output format not supported
What it means
OutputFormatNotSupportedError (a BaseError, IllegalArgumentError → exit 2) from stringifyFormattedOutput's default case (output.ts:101). Fires when a 'formatted'-kind output is asked for a format string not in {'', 'text', 'json', 'yaml', 'name'}. The actual user message is 'format <fmt> is not supported by this command'. Realistically reached when a command forwards a user-supplied -o value without validating against its own format allowlist, or when OutputFormat gains a new constant that formatted output hasn't been taught.
Source
Thrown at cli/src/framework/output.ts:101
return stringifyTableOutput(output)
case 'formatted':
return stringifyFormattedOutput(output)
}
}
function stringifyFormattedOutput(output: FormattedOutput<FormattedPrintable>): string {
switch (output.format) {
case '':
case OutputFormat.TEXT:
return output.data.text()
case OutputFormat.JSON:
return `${JSON.stringify(output.data.json(), null, 2)}\n`
case OutputFormat.YAML:
return dump(output.data.json(), { indent: 2, lineWidth: -1 })
case OutputFormat.NAME:
return `${toName(output.data)}\n`
default:
throw new OutputFormatNotSupportedError(output.format)
}
}
function stringifyTableOutput(output: TableOutput<TablePrintable>): string {
switch (output.format) {
case '':
case OutputFormat.WIDE:
return renderTable(output)
case OutputFormat.JSON:
return `${JSON.stringify(output.data.json(), null, 2)}\n`
case OutputFormat.YAML:
return dump(output.data.json(), { indent: 2, lineWidth: -1 })
case OutputFormat.NAME:
return `${toName(output.data)}\n`
default:
throw new OutputFormatNotSupportedError(output.format)
}
}View on GitHub (pinned to ef8544b173)
Solutions
- Use a format the command advertises in --help (formatted commands typically support text/json/yaml/name).
- Avoid `-o wide` for non-table commands — wide is for table output only (see [50]).
- If you maintain the command, either restrict the flag's `options` to the implemented set or add the missing case to stringifyFormattedOutput.
- Check `difyctl --version` and update — the format may have been added in a newer release.
Example fix
// before — 'wide' is not valid for formatted output difyctl config view -o wide // after — pick a format the formatted path supports difyctl config view -o yaml // or difyctl config view -o json
Defensive patterns
Strategy: validation
Validate before calling
// restrict format choices to the formatted-output set
const FORMATTED_FORMATS = ['text', 'json', 'yaml', 'name'] as const
function assertFormattedFormat(fmt: string): void {
if (!(FORMATTED_FORMATS as readonly string[]).includes(fmt)) {
throw new Error(`formatted-output commands support ${FORMATTED_FORMATS.join(', ')}, not ${fmt}`)
}
} Type guard
function isFormattedFormat(fmt: string): boolean {
return ['text', 'json', 'yaml', 'name'].includes(fmt)
} Prevention
- Never pass `-o wide` to a non-table command; wide is table-only.
- Mirror the command's advertised `options` array from --help in your wrapper.
- When adding a new OutputFormat constant, update both switches and the flag's options list.
When it happens
Trigger: A formatted-output command (e.g. one returning `formatted({format, data})`) is invoked with `-o wide` (wide is table-only), `-o csv`, or any future format not implemented for the formatted path. Also an internal bug where a command sets a literal format string the switch doesn't cover.
Common situations: User assumes all formats work for all commands; a command's outputFormatFlag advertises a restricted set but the dispatcher passes something else; version skew after a new format constant is added to OutputFormat but not to the switch.
Related errors
- usage_invalid_flag
- expected integer, got ${JSON.stringify(raw)}
- expected boolean, got ${JSON.stringify(raw)}
- unsupported argument value
- {label} JSON is invalid: {exc.msg}
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/0bc83d6aa271d508.
Report an issue: GitHub.