{"record":{"id":"9a23b092601c0f41","repo":"FlowiseAI/Flowise","slug":"mime-type-mimetype-is-not-supported-or-does-n","errorCode":null,"errorMessage":"MIME type \"${mimetype}\" is not supported or does not have a valid file extension mapping","messagePattern":"MIME type \"(.+?)\" is not supported or does not have a valid file extension mapping","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/components/src/validator.ts","lineNumber":161,"sourceCode":"    validateFilename(filename)\n\n    if (!mimetype || typeof mimetype !== 'string') {\n        throw new Error('Invalid MIME type: MIME type is required and must be a string')\n    }\n\n    const normalizedExt = extractFileExtension(filename)\n\n    if (!normalizedExt) {\n        // Files without extensions are rejected for security\n        throw new Error('File type not allowed: files must have a valid file extension')\n    }\n\n    // Get the expected extension from mapMimeTypeToExt (returns extension without dot)\n    const expectedExt = mapMimeTypeToExt(mimetype)\n\n    if (!expectedExt) {\n        // If mapMimeTypeToExt doesn't recognize the MIME type, it's not supported\n        throw new Error(`MIME type \"${mimetype}\" is not supported or does not have a valid file extension mapping`)\n    }\n\n    // Ensure the file extension matches the expected extension for the MIME type\n    if (normalizedExt !== expectedExt) {\n        throw new Error(\n            `MIME type mismatch: file extension \"${normalizedExt}\" does not match declared MIME type \"${mimetype}\". Expected: ${expectedExt}`\n        )\n    }\n}\n\n/**\n * Filters an array of MIME type strings to only those allowed for file upload config.\n * Used when sanitizing chatbotConfig.allowedUploadFileTypes to prevent malicious values.\n * @param {string[]} mimeTypes Raw MIME types (e.g. from splitting comma-separated config)\n * @returns {string[]} Only MIME types that pass isAllowedUploadMimeType\n */\nexport const filterAllowedUploadMimeTypes = (mimeTypes: string[]): string[] => {\n    if (!Array.isArray(mimeTypes)) return []","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/src/validator.ts#L143-L179","documentation":"Thrown when mapMimeTypeToExt(mimetype) returns empty — the declared MIME type is not in Flowise's known MIME→extension mapping table. Even though the filename has an extension and the MIME is a non-empty string, Flowise cannot verify the pairing because the MIME type itself is unrecognised, so it rejects by default.","triggerScenarios":"Client declares an exotic MIME (application/x-foo, model/gltf-binary) absent from mapMimeTypeToExt; typo in the MIME (image/jpg vs image/jpeg handled, but 'image/jpeg ' with trailing space is not); a legitimate but unmapped MIME the deployment wants to support.","commonSituations":"Allowing new file types without updating the MIME map; clients sending vendor-specific MIME types; MIME strings with whitespace/casing that aren't normalised before lookup.","solutions":["Check mapMimeTypeToExt for the declared MIME; if absent and the type is legitimately supported, extend the map.","Normalise the MIME before validation (trim + lowercase).","Reject the upload with a 415 Unsupported Media Type for genuinely unsupported types.","Confirm the client sends a standard, mapped MIME (image/png, application/pdf, etc.)."],"exampleFix":"// before\nconst expectedExt = mapMimeTypeToExt(mimetype)\nif (!expectedExt) throw new Error(`MIME type \"${mimetype}\" is not supported ...`)\n\n// after — normalise then map, fall back to extension whitelist\nconst normalized = mimetype.trim().toLowerCase()\nconst expectedExt = mapMimeTypeToExt(normalized)\nif (!expectedExt) {\n  return res.status(415).json({ error: `Unsupported media type: ${normalized}` })\n}","handlingStrategy":"validation","validationCode":"import { mapMimeTypeToExt } from './utils'\nfunction isMappedMimeType(mime: string): boolean {\n  return Boolean(mapMimeTypeToExt(mime.trim().toLowerCase()))\n}","typeGuard":"function isSupportedMimeType(mime: string): boolean {\n  return typeof mapMimeTypeToExt(mime.trim().toLowerCase()) === 'string' && mapMimeTypeToExt(mime.trim().toLowerCase()).length > 0\n}","tryCatchPattern":"const normalized = mimetype.trim().toLowerCase()\nif (!isSupportedMimeType(normalized)) {\n  throw new Error(`MIME type \"${normalized}\" is not supported or does not have a valid file extension mapping`)\n}","preventionTips":["Keep mapMimeTypeToExt in sync with the file types you want to accept.","Normalise MIME strings (trim + lowercase) before lookup.","Return 415 Unsupported Media Type for unmapped MIMEs at the handler boundary."],"tags":["validation","file-upload","mime","config","security"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}