Repository navigation
fix(platform): validate required columns on product CSV import - #1793
Conversation
A product CSV/Excel whose header row used wrong or misnamed columns was accepted silently: header-based mapping left fields undefined, numeric columns fell back to 0, and rows could be imported misaligned instead of surfacing the problem. Opt the product importer into the existing required-column validation (already used for customer/vendor imports). Define PRODUCT_REQUIRED_COLUMNS (name — with the title alias — plus price and stock) and pass it to useFileImport. A file missing any of them now fails up front with a clear "Missing required column(s): … Found columns: …" error instead of importing garbage. Optional columns keep their per-field defaults. Closes #1308
|
Warning Review limit reached
More reviews will be available in 44 minutes and 25 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Importing a product CSV/Excel with the wrong column order or misnamed headers was accepted silently — header-based mapping left fields
undefined, numeric columns (price/stock) fell back to0, and data could land misaligned. No error told the user the file's columns were wrong.Reported in #1308.
Change
The required-column validation already exists in
file-parsing.ts(detectMissingColumns→Missing required column(s): … Found columns: …) and is used by customer/vendor imports viaCONTACT_REQUIRED_COLUMNS— the product importer just never opted in.PRODUCT_REQUIRED_COLUMNS:name(with thetitlealias the record mapper already accepts),price, andstock.useFileImportin the products import dialog.Now a file whose header row is missing any of those fails up front with a clear error naming the missing column(s) and the columns actually found — instead of importing misaligned/zero-filled rows. Optional columns (description, imageUrl, currency, category, status) keep their per-field defaults.
Testing
New cases in
use-file-import.test.ts(30 pass total): all-required-present imports rows,titlealias accepted, wrong/misnamed headers fail with the full missing-column list + found columns, and a single missing column (stock) is reported specifically.tsc --noEmitandoxlint --type-awareclean.Closes #1308