Skip to content

fix(platform): validate required columns on product CSV import - #1793

Merged
yannickmonney merged 1 commit into
mainfrom
fix/product-import-required-columns
Jun 1, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/product-import-required-columns

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

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 to 0, 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 via CONTACT_REQUIRED_COLUMNS — the product importer just never opted in.

  • Add PRODUCT_REQUIRED_COLUMNS: name (with the title alias the record mapper already accepts), price, and stock.
  • Pass it to useFileImport in 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, title alias accepted, wrong/misnamed headers fail with the full missing-column list + found columns, and a single missing column (stock) is reported specifically.

tsc --noEmit and oxlint --type-aware clean.

Closes #1308

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
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@yannickmonney, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0c1595fc-bc09-4140-8a49-4d4536d3d8db

📥 Commits

Reviewing files that changed from the base of the PR and between 5174511 and 1261a35.

📒 Files selected for processing (3)
  • services/platform/app/features/products/components/products-import-dialog.tsx
  • services/platform/app/hooks/use-file-import.test.ts
  • services/platform/app/hooks/use-file-import.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/product-import-required-columns

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yannickmonney
yannickmonney merged commit 6bce8ed into main Jun 1, 2026
28 checks passed
@yannickmonney
yannickmonney deleted the fix/product-import-required-columns branch June 1, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect CSV сolumn with products mapping causes NaN values and misaligned data

1 participant