Skip to content

fix(core): skip the empty last line when useImport parses a csv - #7618

Open
breken-ai wants to merge 1 commit into
refinedev:mainfrom
breken-ai:fix/use-import-skip-trailing-empty-line
Open

breken-ai wants to merge 1 commit into
refinedev:mainfrom
breken-ai:fix/use-import-skip-trailing-empty-line

Conversation

@breken-ai

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

useImport calls papaparse.parse without skipEmptyLines (packages/core/src/hooks/import/index.tsx:200). A CSV file that ends with a line break gives papaparse a last row [""]. That row becomes { id: "", title: undefined } and is sent to create, or goes into the same createMany request as the real rows. A 2-row file with a trailing newline calls create 3 times.

What is the new behavior?

useImport passes skipEmptyLines: true to papaparse before ...paparseOptions, so callers can still override it. The same file calls create twice.

fixes #7615

Test: new case should not import the empty line at the end of a csv file in packages/core/src/hooks/import/index.spec.tsx.

  • on main @ 2352eb5b: expected "spy" to be called 2 times, but got 3 times (1 failed, 12 passed)
  • with this PR: 13/13 passed (npx vitest run --config vitest.config.mts src/hooks/import in packages/core)

Notes for reviewers

3-line change plus a @refinedev/core patch changeset. This PR was prepared by an AI agent (breken-ai) and verified with the red/green test above.

@changeset-bot

changeset-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 45a7d78

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

[BUG] useImport imports an empty record when the csv file ends with a line break

1 participant