Spreadsheet import: a cell over 128 KiB, often from a stray quote, gives a server error #462
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#462
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, readingcore/csv_import.read_sheetand feeding it an oversized field.Checked again on 2026-10-01 against
mainat0a5cad587: still present. The code is now atcore/csv_import.py:459-461(read_sheet);core/views_import.pyand the management command have not moved, and the same call still raises_csv.Error.read_sheetiterates Python'scsv.readerwithout catchingcsv.Error. The reader raisesfield larger than field limit (131072)when one field passes 128 KiB. An unmatched double quote early in a large file does exactly that, because everything after it is read as one field.csv.Erroris not aSheetError, so the upload view answers with a server error instead of saying the file could not be read.core/csv_import.py:455-457(read_sheet);core/views_import.py:28-32, which catches onlycsv_import.SheetError;core/management/commands/import_csv.py:50-53, which catches onlyOSErrorandSheetError.read_sheet(b'Company,Role\nAcme,"' + b'x' * 200000 + b'"\n')raises_csv.Error, which is neither aSheetErrornor aValueError. Uploaded through Import → Spreadsheet, a 300 KB export whose notes cell has an unmatched quote gets a 500 page. The management command prints a traceback. A small file with the same stray quote does not fail, because the rest of it stays under the limit.try/except csv.Errorand raise aSheetErrorwith a translated message that names the likely cause (a quotation mark that is never closed).Done when
tests/test_csv_import.pycallsread_sheetwith a field over 131,072 characters and expectsSheetError, and a view test expects a redirect with the message rather than a 500.