Repository navigation
Description
👟 Reproduction steps
- TablesDB table with
varchar,integer,float,boolean,datetime,enum,email,varchar[],integer[],textcolumns, all optional. - Import one small CSV per case below with
POST /v1/migrations/csv/imports(onDuplicate: fail) and read the row back. - Export the table with
POST /v1/migrations/csv/exportsand re-import the file into an identical empty table (internalFile: true).
👍 Expected behavior
A value is imported as written or the row is reported as an error. Nothing is changed or dropped without a warning, the counters match what was stored, and a CSV export can be re-imported without loss.
👎 Actual Behavior
Two runs, identical. Every case below finished with status completed and no error or warning unless noted.
| CSV cell | Column | Stored |
|---|---|---|
null |
varchar / text | NULL (a value "null" cannot be imported; export → re-import turns "null" into NULL) |
" pad " (quoted) |
varchar | pad (also lost on export → re-import) |
abc, 0x1A, 1,5 |
integer / float | NULL |
1.7 |
integer | 1 |
9999999999999999999999 |
integer | 9223372036854775807 |
maybe |
boolean | NULL |
31.02.2026 |
datetime | 2026-03-03T00:00:00.000+00:00 |
yesterday |
datetime | the date of the previous day |
[1,"x",3] |
integer[] | [1, 0, 3] |
| empty | enum / email | '' → structure error, whole batch rejected (empty means NULL for numbers, booleans and dates; for arrays null is rejected and empty means []) |
Other cases:
- Partial import with wrong counters: rows are written in batches of 100. One bad row (wrong column count in line 251, or a value too long in row 200 of 300) stores the first 200 rows, drops the rest and ends
failed. In the second case the counters saysuccess: 299, error: 1; 200 rows were stored. - UTF-8 with BOM (Excel's "CSV UTF-8"): the first header
$idis not recognised, the row gets a random ID. A second import of the same file creates duplicates. - Latin-1 byte in one row (
M\xfcller): statuscompleted,success: 2, but neither that row nor the valid second row of the same file is stored. There is no error in the migration or in the worker log, and Postgres receives no insert.
Cause, mostly by design of the parser: Sources/CSV.php in utopia-php/migration 2.0.8 trims every value, maps the literal null to NULL and turns non-numeric/non-boolean values into NULL or casts them ((int)$parsedValue), lines 336–370. The comment says "'null' unquoted literal is converted to null", but quoting cannot be detected after parsing, so quoted "null" is converted too.
🎲 Appwrite version
2.4.0 (utopia-php/migration 2.0.8)
💻 Operating system
Linux (Debian 12), Docker
🧱 Your Environment
Self-hosted Appwrite 2.4.0, Postgres adapter, files in a project bucket.
💡 Suggested fix
- Report values that do not parse for their column type as row errors (or at least warnings) instead of storing
NULLor a cast value. - Keep the literal
nullonly for unquoted cells, and don't trim quoted values; or writeNULLdifferently in exports so export → import round-trips. - Treat an empty cell as
NULLfor every optional non-string column (enum, email, url, ip, arrays), consistently. - Strip a UTF-8 BOM, and reject invalid UTF-8 with an error instead of dropping the batch.
- Count a row as
successonly after its batch was written, and document (or make configurable) that imports are not atomic.
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find a similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
Activity