Skip to content

[Bug][Org] A failed teams or users CSV upload returns success, deletes all rows, and blocks later uploads #9447

Done

Description

@henry-rystic

Search before asking

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

What happened

There are two related problems in the CSV uploads of the org plugin (teams.csv, users.csv, user_account_mapping.csv).

Problem 1: a failed write returns success.

  • Each handler first deletes all rows (team.go:87, user.go:90 and :94, user_account_mapping.go:80). Then it calls dbStore.save.
  • The batch size is 1000 (store.go:45). For a normal file, the rows are written only when save calls d.driver.Close() (store.go:122). The error from Close() is ignored.
  • So when the write fails, the API still returns {"success":true}, and the table is empty. For example, the write fails when a value is longer than its column (MySQL strict mode is on by default).

Problem 2: after one failure, every later upload of the same type fails.

  • dbStore uses one BatchSaveDivider for its whole life (store.go:45).
  • ForType keeps one BatchSave per type in a cache. Close does not clear this cache.
  • BatchSave keeps the write error in lastErr (batch_save.go:133). After that, Add rejects every row with add slot failed due to previous err (batch_save.go:90).
  • So every later upload of that type returns 500 until DevLake restarts. Each of these uploads also deletes the existing rows first.

What do you expect to happen

  • When an upload fails, the API returns an error, and the existing rows do not change.
  • A failed upload does not affect later uploads.

How to reproduce

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

  1. Send PUT /plugins/org/teams.csv with a file of three teams (header Id,Name,Alias,ParentId,SortingIndex). Result: {"success":true}. GET /plugins/org/teams.csv lists the three teams.
  2. Send the same three teams and a fourth team whose Name has 300 characters. Result: 200 {"success":true}. GET /plugins/org/teams.csv returns only the header row, and the teams table has 0 rows. The log shows Error 1406 (22001): Data too long for column 'name' at row 4.
  3. Send the file from step 1 again. Result: 500 add slot failed due to previous err ... Data too long for column 'name' at row 4. The teams table is still empty.
  4. Restart DevLake and send the same file. Result: success. The three teams are back.

A users.csv upload between step 3 and step 4 works. Only the type that failed is blocked.

Anything else

It happens every time when MySQL strict mode is on (the default).

Possible fix: create a new divider for each upload, return the error from Close(), and run the delete and the save in one transaction.

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][Org] A failed teams/users upload reports success, empties the table, and breaks later uploads until restart[/-] [+][Bug][Org] A failed teams or users CSV upload returns success, deletes all rows, and blocks later uploads[/+] on Nov 25, 2026
  2. added a commit that references this issue on Nov 25, 2026
    34f1724
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