Admin CSV import rejects valid .csv files on Windows (MIME type check)
#15,416 建立於 2026年5月17日
倉庫指標
- 星標
- (22,539 顆星)
- PR 合併指標
- (平均合併 10天 22小時) (30 天內合併 185 個 PR)
描述
Bug Report
Description
The product import CSV upload in the admin dashboard rejects valid .csv files on Windows machines where Microsoft Excel is installed. The error displayed is:
'{filename}.csv' is not a supported file type. Supported file types are: .csv.
Root Cause
The UploadImport component validates files by checking file.type (MIME type) against ["text/csv"]:
// packages/admin/dashboard/src/routes/products/product-import/components/upload-import.tsx
const SUPPORTED_FORMATS = ["text/csv"]
const hasInvalidFiles = (fileList: FileType[]) => {
const invalidFile = fileList.find(
(f) => !SUPPORTED_FORMATS.includes(f.file.type)
)
// ...
}
On Windows with Excel installed, the registry key HKEY_CLASSES_ROOT\.csv has Content Type set to application/vnd.ms-excel instead of text/csv. The browser reports this system-level MIME type, causing the validation to fail despite the file having a valid .csv extension.
Suggested Fix
Check the file extension instead of the MIME type, since MIME type detection is unreliable across operating systems:
const hasInvalidFiles = (fileList: FileType[]) => {
const invalidFile = fileList.find(
(f) => !f.file.name.toLowerCase().endsWith(".csv")
)
// ...
}
Alternatively, expand SUPPORTED_FORMATS to include common CSV MIME types:
const SUPPORTED_FORMATS = ["text/csv", "application/vnd.ms-excel", "application/csv", "text/plain"]
Environment
- Medusa version: 2.15.2
- OS: Windows 11 with Microsoft Excel installed
- Browsers affected: All (Chrome, Edge, Firefox) — MIME type comes from the OS registry
Steps to Reproduce
- Install Microsoft Excel on a Windows machine (or have it pre-installed)
- Open the Medusa admin dashboard
- Navigate to Products → Import
- Try to upload any valid
.csvfile - Observe the error: "not a supported file type"
Workaround
Users can fix the Windows registry to reassign the CSV MIME type:
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\.csv" -Name "Content Type" -Value "text/csv"
Then restart the browser.