{"record":{"id":"0bc83d6aa271d508","repo":"langgenius/dify","slug":"output-format-not-supported","errorCode":null,"errorMessage":"output format not supported","messagePattern":"output format not supported","errorType":"exception","errorClass":"OutputFormatNotSupportedError","httpStatus":null,"severity":"error","filePath":"cli/src/framework/output.ts","lineNumber":101,"sourceCode":"      return stringifyTableOutput(output)\n    case 'formatted':\n      return stringifyFormattedOutput(output)\n  }\n}\n\nfunction stringifyFormattedOutput(output: FormattedOutput<FormattedPrintable>): string {\n  switch (output.format) {\n    case '':\n    case OutputFormat.TEXT:\n      return output.data.text()\n    case OutputFormat.JSON:\n      return `${JSON.stringify(output.data.json(), null, 2)}\\n`\n    case OutputFormat.YAML:\n      return dump(output.data.json(), { indent: 2, lineWidth: -1 })\n    case OutputFormat.NAME:\n      return `${toName(output.data)}\\n`\n    default:\n      throw new OutputFormatNotSupportedError(output.format)\n  }\n}\n\nfunction stringifyTableOutput(output: TableOutput<TablePrintable>): string {\n  switch (output.format) {\n    case '':\n    case OutputFormat.WIDE:\n      return renderTable(output)\n    case OutputFormat.JSON:\n      return `${JSON.stringify(output.data.json(), null, 2)}\\n`\n    case OutputFormat.YAML:\n      return dump(output.data.json(), { indent: 2, lineWidth: -1 })\n    case OutputFormat.NAME:\n      return `${toName(output.data)}\\n`\n    default:\n      throw new OutputFormatNotSupportedError(output.format)\n  }\n}","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/framework/output.ts#L83-L119","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — 'wide' is not valid for formatted output\ndifyctl config view -o wide\n\n// after — pick a format the formatted path supports\ndifyctl config view -o yaml\n// or\ndifyctl config view -o json","handlingStrategy":"validation","validationCode":"// restrict format choices to the formatted-output set\nconst FORMATTED_FORMATS = ['text', 'json', 'yaml', 'name'] as const\nfunction assertFormattedFormat(fmt: string): void {\n  if (!(FORMATTED_FORMATS as readonly string[]).includes(fmt)) {\n    throw new Error(`formatted-output commands support ${FORMATTED_FORMATS.join(', ')}, not ${fmt}`)\n  }\n}","typeGuard":"function isFormattedFormat(fmt: string): boolean {\n  return ['text', 'json', 'yaml', 'name'].includes(fmt)\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","output","format","validation"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}