{"record":{"id":"55498ebc172c98ca","repo":"DIYgod/RSSHub","slug":"unhandled-media-type-media-mimetype","errorCode":null,"errorMessage":"Unhandled media type: ${media.mimetype}","messagePattern":"Unhandled media type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/fansly/utils.tsx","lineNumber":138,"sourceCode":"\nconst parseMedia = (contentId, accountMedia) => {\n    const media = accountMedia.find((media) => media.id === contentId);\n    if (!media) {\n        return '';\n    }\n    return renderMedia(media.preview ?? media.media);\n};\n\nconst renderMedia = (media) => {\n    switch (media.mimetype) {\n        case 'image/gif':\n        case 'image/jpeg':\n        case 'image/png':\n        case 'video/mp4':\n        case 'audio/mp4':\n            return renderToString(<FanslyMedia poster={media.mimetype === 'video/mp4' ? media.variants[0].locations[0] : null} src={media.locations[0]} />);\n        default:\n            throw new Error(`Unhandled media type: ${media.mimetype}`);\n    }\n};\n\nconst renderPoll = (pollId, polls) => {\n    const poll = polls.find((poll) => poll.id === pollId);\n    return renderToString(<FanslyPoll title={poll.question} options={poll.options} version={poll.version} />);\n};\nconst renderTipGoal = (tipGoalId, tipGoals) => {\n    const goal = tipGoals.find((goal) => goal.id === tipGoalId);\n    return renderToString(<FanslyTipGoal label={goal.label} currentPercentage={goal.currentPercentage} currentAmount={goal.currentAmount} goalAmount={goal.goalAmount} />);\n};\n\nexport { baseUrl, findAccountById, getAccountByUsername, getTagId, getTagSuggestion, getTimelineByAccountId, icon, parseAttachments, parseDescription, parseMedia, renderMedia, renderPoll, renderTipGoal };\n\nconst FanslyMedia = ({ poster, src }: { poster?: { location?: string } | null; src?: { location?: string } }) => (\n    <>\n        {poster && src ? (\n            <video controls preload=\"metadata\" poster={poster.location}>","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/fansly/utils.tsx#L120-L156","documentation":"renderMedia switches on `media.mimetype` and handles only image/gif, image/jpeg, image/png, video/mp4, and audio/mp4; every other mimetype hits `default` and throws a generic Error. This is a parser-completeness gap.","triggerScenarios":"Fansly serves a media file in a format not in the list — e.g. image/webp, image/heic, video/webm, video/quicktime.","commonSituations":"Fansly rolls out a new upload format; the error appears only on posts containing the new format.","solutions":["Add the new mimetype to the switch (rendering it through FanslyMedia if the format is browser-compatible).","As a stopgap, return an empty string in the `default` arm.","If the format is not browser-playable, fall back to a poster/placeholder instead of throwing."],"exampleFix":"// before\n//   case 'audio/mp4':\n//       return renderToString(<FanslyMedia ... />);\n//   default:\n//       throw new Error(`Unhandled media type: ${media.mimetype}`);\n// after\n//   case 'audio/mp4':\n//   case 'image/webp':\n//   case 'video/webm':\n//       return renderToString(<FanslyMedia ... />);\n//   default:\n//       return '';","handlingStrategy":"fallback","validationCode":"const HANDLED_MIME = new Set(['image/gif', 'image/jpeg', 'image/png', 'video/mp4', 'audio/mp4']);\nfunction isHandledMime(media: { mimetype: string }): boolean {\n  return HANDLED_MIME.has(media.mimetype);\n}","typeGuard":"function isHandledMime(media: { mimetype: string }): boolean {\n  return HANDLED_MIME.has(media.mimetype);\n}","tryCatchPattern":"try {\n  return renderMedia(media);\n} catch {\n  return '';\n}","preventionTips":["Return '' in the default arm so one unsupported format does not fail the post.","Add common modern formats (image/webp, video/webm) proactively.","Telemetry on unknown mimetypes."],"tags":["api","parsing","switch-default","mime"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}