{"record":{"id":"e9fb2a3f056f9cf2","repo":"hcengineering/platform","slug":"unknown-content-format","errorCode":null,"errorMessage":"Unknown content format","messagePattern":"Unknown content format","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/api-client/src/markup/client.ts","lineNumber":76,"sourceCode":"    objectClass: Ref<Class<Doc>>,\n    objectId: Ref<Doc>,\n    objectAttr: string,\n    doc: MarkupRef,\n    format: MarkupFormat\n  ): Promise<string> {\n    const collabId = makeCollabId(objectClass, objectId, objectAttr)\n    const markup = await this.collaborator.getMarkup(collabId, doc)\n    const json = markupToJSON(markup)\n\n    switch (format) {\n      case 'markup':\n        return markup\n      case 'html':\n        return jsonToHTML(json)\n      case 'markdown':\n        return markupToMarkdown(json, { refUrl: this.refUrl, imageUrl: this.imageUrl })\n      default:\n        throw new Error('Unknown content format')\n    }\n  }\n\n  async uploadMarkup (\n    objectClass: Ref<Class<Doc>>,\n    objectId: Ref<Doc>,\n    objectAttr: string,\n    value: string,\n    format: MarkupFormat\n  ): Promise<MarkupRef> {\n    let markup: Markup = ''\n\n    switch (format) {\n      case 'markup':\n        markup = value\n        break\n      case 'html':\n        markup = jsonToMarkup(htmlToJSON(value))","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/api-client/src/markup/client.ts#L58-L94","documentation":"fetchMarkup converts stored collaborative markup into a requested format ('markup', 'html', or 'markdown'). If the format argument matches none of these cases, the switch falls through to default and throws 'Unknown content format'. This indicates an invalid or unsupported MarkupFormat value at runtime.","triggerScenarios":"Calling fetchMarkup(objectClass, objectId, attr, doc, format) with format that is not exactly 'markup' | 'html' | 'markdown' — e.g. 'md', 'text', 'richtext', or a value cast incorrectly to MarkupFormat.","commonSituations":"Hand-building a format string instead of using the MarkupFormat type, user-configurable export format from a UI/config reaching the API unvalidated, TypeScript types bypassed with `as MarkupFormat`.","solutions":["Pass exactly one of 'markup', 'html', or 'markdown' as the format argument.","Validate/normalize the format string (lowercase, map aliases like 'md' -> 'markdown') before calling fetchMarkup.","Use the MarkupFormat type and avoid unchecked casts so TypeScript rejects invalid values."],"exampleFix":"// before\nclient.fetchMarkup(cls, id, 'content', doc, 'md' as MarkupFormat)\n// after\nconst fmt = format === 'md' ? 'markdown' : format\nif (!['markup', 'html', 'markdown'].includes(fmt)) throw new Error('unsupported format: ' + format)\nclient.fetchMarkup(cls, id, 'content', doc, fmt as MarkupFormat)","handlingStrategy":"validation","validationCode":"const FORMATS = ['markup', 'html', 'markdown'] as const\nif (!FORMATS.includes(format as any)) throw new Error(`Invalid markup format: ${format}; expected one of ${FORMATS.join(', ')}`)","typeGuard":"function isMarkupFormat(v: unknown): v is 'markup' | 'html' | 'markdown' {\n  return v === 'markup' || v === 'html' || v === 'markdown'\n}","tryCatchPattern":"try {\n  return await client.fetchMarkup(cls, id, attr, doc, format)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Unknown content format') {\n    throw new Error(`Unsupported export format \"${String(format)}\" — use 'markup', 'html' or 'markdown'`)\n  }\n  throw e\n}","preventionTips":["Always type format parameters as MarkupFormat and avoid `as` casts from raw strings","Normalize external input (toLowerCase, alias map like md->markdown) before calling","Unit-test each supported format string your UI can produce"],"tags":["validation","markup","typescript"],"backgroundTag":"invalid-enum-value","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}