{"record":{"id":"8e6a344ac9670e7f","repo":"apify/crawlee","slug":"can-not-parse-mime-type-mimetype-from-options","errorCode":null,"errorMessage":"Can not parse mime type ${mimeType} from \"options.additionalMimeTypes\".","messagePattern":"Can not parse mime type (.+?) from \"options\\.additionalMimeTypes\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/http-crawler/src/internals/http-crawler.ts","lineNumber":852,"sourceCode":"\n        throw new Error(`Resource ${request.url} served with unsupported charset/encoding: ${encoding}`);\n    }\n\n    /**\n     * Checks and extends supported mime types\n     */\n    private extendSupportedMimeTypes(additionalMimeTypes: (string | RequestLike | ResponseLike)[]) {\n        for (const mimeType of additionalMimeTypes) {\n            if (mimeType === '*/*') {\n                this.#supportedMimeTypes.add(mimeType);\n                continue;\n            }\n\n            try {\n                const parsedType = contentTypeParser.parse(mimeType);\n                this.#supportedMimeTypes.add(parsedType.type);\n            } catch (err) {\n                throw new Error(`Can not parse mime type ${mimeType} from \"options.additionalMimeTypes\".`);\n            }\n        }\n    }\n\n    /**\n     * Handles timeout request\n     */\n    private handleRequestTimeout(session: ISession) {\n        session.markBad();\n        throw new Error(`Request timed out after ${this.#navigationTimeoutMillis / 1000} seconds.`);\n    }\n\n    private abortDownloadOfBody(request: CrawleeRequest, response: Response) {\n        const { status } = response;\n        const { type } = parseContentTypeFromResponse(response);\n\n        const isTransientContentType = status >= 500 || this.blockedStatusCodes.has(status);\n","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/http-crawler/src/internals/http-crawler.ts#L834-L870","documentation":"The constructor runs every entry of `additionalMimeTypes` through the content-type parser so it can map them to supported MIME types; if a value cannot be parsed (invalid string or object shape), it throws this error and the crawler never starts. This is a fail-fast configuration validation error.","triggerScenarios":"Passing malformed values in `options.additionalMimeTypes` — e.g. 'json' without a type, 'application/', an empty string, or an object lacking the required type/parse shape.","commonSituations":"Typing `'additionalMimeTypes': ['json']` instead of `'application/json'`; a comma-joined string instead of an array; mistyping a MIME like 'text/jason'; passing a RequestLike/ResponseLike object missing expected properties.","solutions":["Use full valid MIME type strings: ['application/json', 'text/plain', 'application/xml'].","Validate each entry with the same parser before constructing: `require('content-type').parse(value)` in a try/catch to find the offender.","If passing objects, ensure they match the RequestLike/ResponseLike contract (must parse to a `.type`).","Pass an array of strings, not one comma-separated string."],"exampleFix":"// before\nnew HttpCrawler({ additionalMimeTypes: ['json', 'text/jason'] });\n\n// after\nnew HttpCrawler({ additionalMimeTypes: ['application/json', 'application/atom+xml'] });","handlingStrategy":"validation","validationCode":"import contentTypeParser from 'content-type';\nfunction validateMimeTypes(types: (string | object)[]): void {\n  for (const t of types) {\n    try { contentTypeParser.parse(String(t)); }\n    catch { throw new Error(`Invalid additionalMimeTypes entry: ${JSON.stringify(t)}`); }\n  }\n}\nvalidateMimeTypes(['application/json', 'application/xml']);","typeGuard":"function isValidMimeType(v: unknown): v is string {\n  if (typeof v !== 'string') return false;\n  try { contentTypeParser.parse(v); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  const crawler = new HttpCrawler({ additionalMimeTypes: userTypes });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('additionalMimeTypes')) {\n    throw new Error(`Config error — fix options.additionalMimeTypes: ${err.message}`);\n  }\n  throw err;\n}","preventionTips":["Always pass full MIME strings like 'application/json', never bare 'json'.","Pass an array of strings, not a comma-separated string.","Validate user-supplied MIME config at app startup, before constructing the crawler.","For objects, confirm they satisfy the RequestLike/ResponseLike contract in the docs."],"tags":["configuration","mime-type","validation","crawler-setup"],"backgroundTag":"invalid-mime-type","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}