fix(import): support CSV files without a header row - #712
fix(import): support CSV files without a header row#7122160039878-cyber wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
cevheri
left a comment
There was a problem hiding this comment.
Almost there. Everything #689 asked for is here, and the tests are real: reverting only DataImportModal.tsx turns five of your six new cases red, so they measure the fix instead of agreeing with it. The checkbox markup matches the existing ConnectionModal SSH pattern exactly, which is the right call over the shadcn primitive.
One change before I merge. The toggle handler always rebuilds columnMapping to identity, so it silently discards target column names the user has already typed. The path is real: Configure Import, rename a target column, Back at line 597, then check and uncheck the box. The headers are byte-identical after that round trip and the mapping is gone anyway, with nothing on screen saying so. I reproduced it: the target for name came back as name instead of full_name.
That is the same shape as the defect #689 is about, a silent loss with no indication, so it is worth closing rather than inheriting. Cheapest fix: rebuild the mapping only when the header set actually changed, and keep the existing entry for any header that survives. A test for the round trip belongs with it.
Two things I found are not yours and I am not asking for them here: a ragged CSV emits an INSERT whose value tuple is wider than the column list, and header text reaches the generated SQL as a bare identifier. Both predate this PR on the header path, and I am tracking them separately.
Description
Importing a CSV without headers currently consumes the first data row as column names. Add a First row is header checkbox to the CSV preview, checked by default. Unchecking it generates
column_1,column_2, etc. and preserves the first row in the preview and generated SQL.Returning from Configure Import and toggling the header option also preserves edited target column names, including an off/on round trip.
Type of Change
Related Issue
Closes #689
Changes Made
parseCSVand reparse the original CSV on each toggle.Testing
Latest review revision:
d691d46e95dcb237630f91db3b0af4db186088d0.bun run test:components --pass-with-no-tests -t 'DataImportModal': 47 passed, 0 failed, using the repository's isolation groups. Other component tests were filtered out.git diff --checkalso passed. Lint reports existing warnings with zero errors.Complete CI and local limitations
Official CI for this revision completed successfully. All nine executable jobs passed: full unit/integration/component tests and the 100% line-coverage gate, lint/typecheck/build, Helm, Node 24/26 smoke, browser and subpath E2E, PostgreSQL smoke, and tarball/npx installation tests. The PR reports 20 successful checks and two expected skips (Image Scan and SonarCloud). CodeQL, Secret Scan, dependency scanning, platform rules, GitGuardian, Socket, Semgrep, and Codecov patch coverage also passed.
The complete
bun run test,bun run test:coverage,bun run coverage:check, Helm dependency/lint commands, and browser E2E were not rerun locally. This Windows host lacks Helm and the chart's PostgreSQL dependency; the earlier full component run also encountered Windows SQLite cleanupEBUSYin unchanged agent tests. Official Linux CI verifies these stages. No repository-wide coverage claim is based on the focused local run.Test Environment
Checklist
Additional Notes
This is AI-assisted work. No dependencies were added.