Skip to content

[Bug][Customize] A failed CSV import deletes existing data and saves part of the file #9448

Todo

Description

@henry-rystic

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

A CSV import with incremental=false (the default) can fail on one row. When this happens, the import has already deleted the data from the previous import, and it has saved the rows before the bad row. The API returns 400, so the user thinks that nothing changed.

Cause:

  • Each import deletes the old data first. Then it calls importCSV.
  • importCSV saves one row at a time, without a transaction, and stops at the first bad row.
  • See backend/plugins/customize/service/service.go: ImportIssue deletes at lines 161-183, and importCSV is at lines 237-264.
  • ImportIssueCommit, ImportIssueRepoCommit, ImportIssueChangelog, ImportIssueWorklog, ImportSprint, ImportQaApis and ImportQaTestCases work the same way. We saw the same data loss for each of them in our tests.

What do you expect to happen

Either the whole file is imported, or nothing changes. When the file is rejected, the board keeps its previous data, and nothing from the file is saved.

How to reproduce

Tested with the image apache/devlake:main_261124_0230_52d63a1 and MySQL 8.4.

  1. Send POST /plugins/customize/csvfiles/issues.csv with boardId=csv-board, boardName=Board, incremental=false, and a file with three valid issues (csv:1, csv:2, csv:3). Result: 200. The board has the three issues.
  2. Send a second file with these rows, in this order: csv:1; a row with too few fields (csv:9,https://example.com/issues/9,9); csv:2; csv:3. Result: 400 error on processing the line:2 ... wrong number of fields.
  3. The board now has only csv:1. csv:2 and csv:3 are deleted from issues and board_issues, but the import was rejected.

If the bad row is the last row, the rows before it are still saved. For example, a title that was changed in the rejected file replaces the old title.

Anything else

It happens every time.

Possible fix: run the delete and the inserts in one transaction, or check the whole file before deleting. This fixes all the import types.

Version

main (52d63a1)

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. changed the title [-][Bug][Customize] A failed CSV import deletes the existing data and keeps part of the file[/-] [+][Bug][Customize] A failed CSV import deletes existing data and saves part of the file[/+] on Nov 25, 2026
  2. added 2 commits that reference this issue on Nov 25, 2026
    cecac71
    d458c31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ Proxy