{"record":{"id":"7ac7bc7566c68a7e","repo":"hcengineering/platform","slug":"invalid-format-supported-formats-supportedexpo","errorCode":null,"errorMessage":"Invalid format. Supported formats: ${supportedExportFormats.join(', ')}","messagePattern":"Invalid format\\. Supported formats: (.+?)","errorType":"http","errorClass":"ApiError","httpStatus":400,"severity":"warning","filePath":"services/export/pod-export/src/server.ts","lineNumber":262,"sourceCode":"      url: wsLoginInfo.workspaceUrl\n    }\n    await fn(req, res, wsIds, token, wsLoginInfo.socialId, next)\n  } catch (err: unknown) {\n    next(err)\n  }\n}\n\nconst wrapRequest = (fn: AsyncRequestHandler) => (req: Request, res: Response, next: NextFunction) => {\n  // eslint-disable-next-line @typescript-eslint/no-floating-promises\n  handleRequest(fn, req, res, next)\n}\n\n// Only formats actually supported by WorkspaceExporter\nconst supportedExportFormats: readonly ExportFormat[] = [ExportFormat.JSON, ExportFormat.CSV]\n\nfunction parseExportFormat (rawFormat: unknown): ExportFormat {\n  if (typeof rawFormat !== 'string' || !supportedExportFormats.includes(rawFormat as ExportFormat)) {\n    throw new ApiError(400, `Invalid format. Supported formats: ${supportedExportFormats.join(', ')}`)\n  }\n  return rawFormat as ExportFormat\n}\n\nfunction toSafeFormatFileToken (format: ExportFormat): 'json' | 'csv' {\n  switch (format) {\n    case ExportFormat.JSON:\n      return 'json'\n    case ExportFormat.CSV:\n      return 'csv'\n    default:\n      throw new ApiError(400, `Invalid format. Supported formats: ${supportedExportFormats.join(', ')}`)\n  }\n}\n\nexport function createServer (\n  storageConfig: StorageConfiguration,\n  dbUrl: string,","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/export/pod-export/src/server.ts#L244-L280","documentation":"parseExportFormat validates the caller-supplied format parameter against the explicitly supported list [ExportFormat.JSON, ExportFormat.CSV]. If format is not a string or not one of those values, it throws this 400 ApiError. Only formats actually implemented by WorkspaceExporter are allowed.","triggerScenarios":"Calling an export endpoint with ?format=xml, ?format=PDF, format omitted from the body/query (undefined), or a non-string value such as format: 123.","commonSituations":"Assuming other formats (XLSX, XML) are supported because the enum in shared code lists more values; typos in case ('JSON' vs 'json' if enum values are lowercase); clients upgraded to send a format the pod-export build predates.","solutions":["Send format as exactly one of the supported values: json or csv.","Check the ExportFormat enum values in your build and match the case exactly.","Add client-side validation limiting the format picker to JSON/CSV.","If you need another format, extend supportedExportFormats and WorkspaceExporter; you cannot get it via config alone."],"exampleFix":"// before\nfetch('/export', { method: 'POST', body: JSON.stringify({ _class, format: 'xlsx' }) })\n// after\nfetch('/export', { method: 'POST', body: JSON.stringify({ _class, format: 'csv' }) })","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['json', 'csv'] as const\nif (typeof format !== 'string' || !SUPPORTED.includes(format as any)) {\n  throw new Error(`Unsupported format: ${String(format)}. Use one of ${SUPPORTED.join(', ')}`)\n}","typeGuard":"function isExportFormat(v: unknown): v is 'json' | 'csv' {\n  return v === 'json' || v === 'csv'\n}","tryCatchPattern":"try {\n  await requestExport({ ...params, format })\n} catch (e) {\n  if (e instanceof ApiError && e.status === 400 && e.message.startsWith('Invalid format')) {\n    return requestExport({ ...params, format: 'json' })\n  }\n  throw e\n}","preventionTips":["Constrain UI/CLI format options to the enum values actually supported by pod-export (json, csv).","Share a single ExportFormat type between client and server instead of free-form strings.","Match enum casing exactly."],"tags":["validation","http-400","parameters","export-format"],"backgroundTag":"invalid-parameter","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}