You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug][Customize] A failed CSV import deletes existing data and saves part of the file #9448
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.
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.
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.
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.
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
Activity
[-][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[/+]fix(customize): make a rejected CSV import change nothing
fix(customize): make a rejected CSV import change nothing