{"record":{"id":"e559bc72ee4951cc","repo":"jellyfin/jellyfin","slug":"unable-to-determine-image-file-extension-from-mime","errorCode":null,"errorMessage":"Unable to determine image file extension from mime type {0}","messagePattern":"Unable to determine image file extension from mime type (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MediaBrowser.Providers/Manager/ImageSaver.cs","lineNumber":403,"sourceCode":"        /// <param name=\"item\">The item.</param>\n        /// <param name=\"type\">The type.</param>\n        /// <param name=\"imageIndex\">Index of the image.</param>\n        /// <param name=\"mimeType\">Type of the MIME.</param>\n        /// <param name=\"saveLocally\">if set to <c>true</c> [save locally].</param>\n        /// <returns>System.String.</returns>\n        /// <exception cref=\"ArgumentNullException\">\n        /// imageIndex\n        /// or\n        /// imageIndex.\n        /// </exception>\n        private string GetStandardSavePath(BaseItem item, ImageType type, int? imageIndex, string mimeType, bool saveLocally)\n        {\n            var season = item as Season;\n            var extension = MimeTypes.ToExtension(mimeType);\n\n            if (string.IsNullOrWhiteSpace(extension))\n            {\n                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, \"Unable to determine image file extension from mime type {0}\", mimeType));\n            }\n\n            if (string.Equals(extension, \".jpeg\", StringComparison.OrdinalIgnoreCase))\n            {\n                extension = \".jpg\";\n            }\n\n            extension = extension.ToLowerInvariant();\n\n            if (type == ImageType.Primary && saveLocally)\n            {\n                if (season is not null && season.IndexNumber.HasValue)\n                {\n                    var seriesFolder = season.SeriesPath;\n\n                    var seasonMarker = season.IndexNumber.Value == 0\n                                           ? \"-specials\"\n                                           : season.IndexNumber.Value.ToString(\"00\", CultureInfo.InvariantCulture);","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/jellyfin/jellyfin/blob/ae8723026d97b6d0f926638803edef338919b794/MediaBrowser.Providers/Manager/ImageSaver.cs#L385-L421","documentation":"ImageSaver.GetStandardSavePath throws when MimeTypes.ToExtension(mimeType) returns null/whitespace, i.e. the mime type is not in the extension lookup. ToExtension strips parameters (charset), checks the lookup table, then falls back to GetMimeTypeExtensions; if both miss it returns null and saving cannot pick a file extension.","triggerScenarios":"Saving an image whose mime type is unrecognized (e.g. \"image/avif\", \"image/heic\", \"application/octet-stream\" with no path fallback, or an exotic vendor mime type).","commonSituations":"A metadata provider returning an unusual image mime type; an avif/heic cover from a newer scraper; a provider reporting a generic mime that ToExtension cannot map.","solutions":["Normalize the mime type to a supported one before saving (e.g. map image/avif -> image/jpeg or register an extension mapping).","Register the mime->extension pair in MimeTypes extensions if the format is genuinely supported by SkiaSharp.","Catch ArgumentException at the save call site and skip/preserve the existing image.","Validate mimeType with !string.IsNullOrWhiteSpace(MimeTypes.ToExtension(mimeType)) before attempting to save."],"exampleFix":"// before\nvar extension = MimeTypes.ToExtension(mimeType);\nif (string.IsNullOrWhiteSpace(extension))\n    throw new ArgumentException(...);\n\n// after\nvar extension = MimeTypes.ToExtension(mimeType);\nif (string.IsNullOrWhiteSpace(extension))\n{\n    _logger.LogWarning(\"Unknown image mime {Mime}, skipping save\", mimeType);\n    return;\n}","handlingStrategy":"validation","validationCode":"var ext = MimeTypes.ToExtension(mimeType);\nif (string.IsNullOrWhiteSpace(ext))\n{\n    _logger.LogWarning(\"Unknown image mime {Mime}\", mimeType);\n    return; // skip save\n}","typeGuard":"static bool HasKnownImageExtension(string mime) =>\n    !string.IsNullOrWhiteSpace(MimeTypes.ToExtension(mime));","tryCatchPattern":"try { path = GetStandardSavePath(item, type, idx, mime, saveLocally); }\ncatch (ArgumentException ex) { _logger.LogWarning(ex.Message); return; }","preventionTips":["Normalize provider mime types to supported ones before saving.","Register mime->extension mappings for new formats.","Skip unknown mime types instead of failing the whole save."],"tags":["images","mime-types","providers","validation"],"backgroundTag":null,"analyzedSha":"ae8723026d97b6d0f926638803edef338919b794","analyzedAt":"2026-08-13T10:43:30.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}