{"record":{"id":"6b12dbd7b599e7cc","repo":"nopSolutions/nopCommerce","slug":"file-is-not-supported","errorCode":null,"errorMessage":"File is not supported.","messagePattern":"File is not supported\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/SettingController.cs","lineNumber":1865,"sourceCode":"                    await _uploadService.UploadFaviconAsync(iconsFile);\n                    commonSettings.FaviconAndAppIconsHeadCode = string.Format(NopCommonDefaults.SingleFaviconHeadLink, storeScope, iconsFile.FileName);\n\n                    break;\n\n                case \".zip\":\n                    await _uploadService.UploadIconsArchiveAsync(iconsFile);\n\n                    var headCodePath = _fileProvider.GetAbsolutePath(string.Format(NopCommonDefaults.FaviconAndAppIconsPath, storeScope), NopCommonDefaults.HeadCodeFileName);\n                    if (!_fileProvider.FileExists(headCodePath))\n                        throw new Exception(string.Format(await _localizationService.GetResourceAsync(\"Admin.Configuration.Settings.GeneralCommon.FaviconAndAppIcons.MissingFile\"), NopCommonDefaults.HeadCodeFileName));\n\n                    using (var sr = new StreamReader(headCodePath))\n                        commonSettings.FaviconAndAppIconsHeadCode = await sr.ReadToEndAsync();\n\n                    break;\n\n                default:\n                    throw new InvalidOperationException(\"File is not supported.\");\n            }\n\n            await _settingService.SaveSettingOverridablePerStoreAsync(commonSettings, x => x.FaviconAndAppIconsHeadCode, true, storeScope);\n\n            //delete old favicon icon if exist\n            var oldFaviconIconPath = _fileProvider.GetAbsolutePath(string.Format(NopCommonDefaults.OldFaviconIconName, storeScope));\n            if (_fileProvider.FileExists(oldFaviconIconPath))\n                _fileProvider.DeleteFile(oldFaviconIconPath);\n\n            //activity log\n            await _customerActivityService.InsertActivityAsync(\"UploadIcons\", string.Format(await _localizationService.GetResourceAsync(\"ActivityLog.UploadNewIcons\"), storeScope));\n            _notificationService.SuccessNotification(await _localizationService.GetResourceAsync(\"Admin.Configuration.FaviconAndAppIcons.Uploaded\"));\n        }\n        catch (Exception exc)\n        {\n            await _notificationService.ErrorNotificationAsync(exc);\n        }\n","sourceCodeStart":1847,"sourceCodeEnd":1883,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/SettingController.cs#L1847-L1883","documentation":"Thrown in the favicon/app-icon upload flow when the uploaded file's extension is neither .ico nor .zip, hitting the default case of the switch and throwing InvalidOperationException('File is not supported.'). It is a hard format gate before any extraction work.","triggerScenarios":"Uploading .png, .jpg, .gif, .svg, or any non-.ico/.zip file to the favicon/app-icons uploader; user mis-selecting an image instead of the prepared ico/zip.","commonSituations":"Operators unfamiliar with the required formats attempting to upload a raw PNG/SVG; automated tooling posting the wrong content type; frontend not restricting accepted extensions.","solutions":["Upload either a single .ico or a prepared .zip of icons; convert other formats first.","Add an `accept=\".ico,.zip\"` attribute on the file input to prevent bad selections.","Pre-validate the extension server-side and return a friendly notification instead of throwing.","Document the accepted formats next to the uploader."],"exampleFix":"// before\ndefault:\n    throw new InvalidOperationException(\"File is not supported.\");\n\n// after\ndefault:\n    _notificationService.ErrorNotification(\"Only .ico and .zip files are supported.\");\n    return View(model);\n// plus client-side:\n// <input type=\"file\" accept=\".ico,.zip\" />","handlingStrategy":"validation","validationCode":"var ext = _fileProvider.GetFileExtension(fileName).ToLowerInvariant();\nif (ext != \".ico\" && ext != \".zip\")\n    return ErrorResult(\"Only .ico and .zip are supported.\");","typeGuard":"static bool IsSupportedIconFile(string fileName)\n{\n    var ext = Path.GetExtension(fileName)?.ToLowerInvariant();\n    return ext == \".ico\" || ext == \".zip\";\n}","tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message == \"File is not supported.\")\n{ _notificationService.ErrorNotification(\"Use .ico or .zip.\"); return View(model); }","preventionTips":["Add accept=\".ico,.zip\" on the file input.","Validate the extension server-side before the switch.","Document accepted formats beside the uploader."],"tags":["nopcommerce","admin-controller","validation","file-upload","favicon","unsupported-format"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}