{"record":{"id":"6c7759f99c463048","repo":"Budibase/budibase","slug":"unsupported-format-format","errorCode":null,"errorMessage":"Unsupported format: ${format}","messagePattern":"Unsupported format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/shared-core/src/helpers/rowsHelper.ts","lineNumber":84,"sourceCode":"  const schemaKeys = columns?.length\n    ? columns.map(c => c.name)\n    : Array.from(new Set(rows.flatMap(row => Object.keys(row))))\n\n  // Normalize rows to ensure every row has all schema keys\n  const filteredRows = rows.map(row =>\n    schemaKeys.reduce((acc: Row, key) => {\n      acc[key] = key in row ? row[key] : \"\"\n      return acc\n    }, {})\n  )\n\n  switch (format) {\n    case \"csv\":\n      return convertRowsToCsv(filteredRows, schemaKeys, delimiter)\n    case \"json\":\n      return convertRowsToJson(filteredRows)\n    default:\n      throw new Error(`Unsupported format: ${format}`)\n  }\n}\n","sourceCodeStart":66,"sourceCodeEnd":87,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/shared-core/src/helpers/rowsHelper.ts#L66-L87","documentation":"convertDataToExportFormat in packages/shared-core/src/helpers/rowsHelper.ts only supports two export formats: \"csv\" (with a delimiter) and \"json\". Any other format string falls into the default branch and throws \"Unsupported format\". This is an intentional whitelist so callers cannot request an unimplemented export type.","triggerScenarios":"Calling the export helper (directly or via row export/download APIs) with format values like \"xlsx\", \"CSV\" (uppercase), \"tsv\", \"excel\", or an undefined/misspelled format variable.","commonSituations":"Hardcoded format strings that don't match the lowercase literals; user-configurable export format options not restricted to csv/json; passing Excel export intent to a helper that only does csv/json.","solutions":["Pass exactly \"csv\" or \"json\" (lowercase).","Normalise user input with format.toLowerCase() and fall back to \"csv\" when unknown.","For Excel/xlsx exports, export CSV and convert with a separate library, or use a dedicated export path.","Restrict UI options to the two supported formats."],"exampleFix":"// before\nconvertDataToExportFormat({ rows, schema, format: \"xlsx\" })\n// after\nconvertDataToExportFormat({ rows, schema, format: \"csv\" })","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"csv\", \"json\"])\nconst fmt = String(requestedFormat ?? \"csv\").toLowerCase()\nif (!SUPPORTED.has(fmt)) {\n  throw new Error(`Format '${requestedFormat}' unsupported; use csv or json`)\n}\nconvertDataToExportFormat({ rows, schema, format: fmt })","typeGuard":"type ExportFormat = \"csv\" | \"json\"\nfunction isExportFormat(v: unknown): v is ExportFormat {\n  return v === \"csv\" || v === \"json\"\n}","tryCatchPattern":"let output: string\ntry {\n  output = convertDataToExportFormat({ rows, schema, format })\n} catch (e) {\n  if (e.message.startsWith(\"Unsupported format\")) {\n    output = convertDataToExportFormat({ rows, schema, format: \"csv\" })\n  } else throw e\n}","preventionTips":["Restrict export UI options to csv and json only","Lowercase/trim user-selected format strings before passing","Default to \"csv\" when the format option is absent","Don't assume xlsx support — convert from CSV with a dedicated library"],"tags":["export","validation","unsupported-format"],"backgroundTag":"unsupported-format","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}