{"record":{"id":"8c4c4be780f04a0f","repo":"basecamp/trix","slug":"unknown-content-type","errorCode":null,"errorMessage":"unknown content type: ","messagePattern":"unknown content type: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"action_text-trix/app/assets/javascripts/trix.js","lineNumber":9977,"sourceCode":"        } catch (error) {}\n      });\n      return element.innerHTML.replace(blockCommentPattern, \"\");\n    }\n  };\n  const deserializers = {\n    \"application/json\": function (string) {\n      return Document.fromJSONString(string);\n    },\n    \"text/html\": function (string) {\n      return HTMLParser.parse(string).getDocument();\n    }\n  };\n  const serializeToContentType = function (serializable, contentType) {\n    const serializer = serializers[contentType];\n    if (serializer) {\n      return serializer(serializable);\n    } else {\n      throw new Error(\"unknown content type: \".concat(contentType));\n    }\n  };\n  const deserializeFromContentType = function (string, contentType) {\n    const deserializer = deserializers[contentType];\n    if (deserializer) {\n      return deserializer(string);\n    } else {\n      throw new Error(\"unknown content type: \".concat(contentType));\n    }\n  };\n\n  var core = /*#__PURE__*/Object.freeze({\n    __proto__: null\n  });\n\n  class ManagedAttachment extends BasicObject {\n    constructor(attachmentManager, attachment) {\n      super(...arguments);","sourceCodeStart":9959,"sourceCodeEnd":9995,"githubUrl":"https://github.com/basecamp/trix/blob/470040131122bd44e269b4de0f2e9557f90ec994/action_text-trix/app/assets/javascripts/trix.js#L9959-L9995","documentation":"serializeToContentType looks up the contentType in a fixed serializers map (\"application/json\", \"text/html\"). Any other or empty content type has no serializer and throws. It indicates an unsupported or misspelled content type string was supplied.","triggerScenarios":"Calling serializeToContentType(data, \"text/plain\"), serializeToContentType(data, \"\"), or with an undefined/mistyped content-type variable.","commonSituations":"Reading a MIME type from an attachment or HTTP header that Trix doesn't support; typos like \"application/JSON\"; passing a variable that is undefined at runtime so the message renders as \"unknown content type: \".","solutions":["Use only supported content types: \"application/json\" or \"text/html\".","Fix case/whitespace: the lookup is exact, so normalize the string (trim, lowercase).","Guard undefined contentType before calling; the empty message suggests an undefined variable.","If you need another format, convert manually via one of the supported serializers."],"exampleFix":"// before\nserializeToContentType(data, attachment.getType()) // may be \"image/png\"\n// after\nconst ct = attachment.getType() === \"application/json\" ? \"application/json\" : \"text/html\"\nserializeToContentType(data, ct)","handlingStrategy":"validation","validationCode":"const SUPPORTED = [\"application/json\", \"text/html\"]\nif (!SUPPORTED.includes(contentType)) {\n  throw new Error(`Unsupported content type: ${contentType}; use one of ${SUPPORTED.join(\", \")}`)\n}","typeGuard":"const isSupportedContentType = (ct) => ct === \"application/json\" || ct === \"text/html\"","tryCatchPattern":"try {\n  return serializeToContentType(data, contentType)\n} catch (e) {\n  if (e.message.startsWith(\"unknown content type\")) {\n    console.warn(`Falling back to text/html; received contentType=${JSON.stringify(contentType)}`)\n    return serializeToContentType(data, \"text/html\")\n  }\n  throw e\n}","preventionTips":["Keep content types as named constants, not raw strings from external data.","Normalize (trim/lowercase) MIME values from attachments or headers before use.","Default to a known type when the source type is unknown."],"tags":["serialization","invalid-argument","trix"],"backgroundTag":"unknown-content-type","analyzedSha":"470040131122bd44e269b4de0f2e9557f90ec994","analyzedAt":"2026-09-02T10:19:15.878Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}