Skip to content

fix(import): refuse files too large to open, and let the file say empty from absent - #581

Merged
EVWorth merged 1 commit into
mainfrom
fix/import-limits
Sep 9, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/import-limits

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Closes #366, #578.

A file too large to show now says so — #366

read_file_contents read whatever it was given. Everything downstream — the Rust string, the JavaScript copy, the parsed rows — is held at once, so a multi-gigabyte CSV took the renderer down before the user saw anything.

It now checks the size from the file's metadata and refuses before reading a byte, naming the size, the limit, and what to do instead. The cap is 256 MB, chosen from what the pipeline survives rather than from disk.

The issue asks for streaming. That's the right long-term answer and a much larger change — chunked reads, a chunked parse, batched inserts driven by the chunks. This isn't that. It's the part that stops the app dying, and it's worth having whether or not streaming is built later.

Applied in the command rather than the dialog, so restore gets it too — it reads whole files the same way.

The file decides empty from absent — #578

Every empty cell became SQL NULL. CSV distinguishes ,, from ,"",, but parseCSVLine discarded the quoting before anyone could act on it — so a NOT NULL column rejected a row the user considered valid, and a nullable one silently stored NULL where the file said "".

The parser now reports which cells were written bare, alongside the rows rather than changing their type, so every existing caller reads them unchanged. A bare empty becomes NULL; a quoted one stays "". A row shorter than its header is absent rather than empty, which is the same reading.

generateBatchInsert takes the flags as an optional argument and behaves exactly as before without them.

Two bugs found while wiring it up

setCsvBareEmpty could be handed undefined by a caller predating the field, and the component then threw on .map when the import ran. Defaulted.

The import callback used the new state without listing it as a dependency — it would have closed over an empty array and treated every cell as absent. Same shape as the grid's memo in #555. Caught by the lint warning, which is what that rule is for.

Tests

Three Rust on the limit (over it refuses and names both sizes, at it succeeds, and the byte formatting), four on the parser, three on the generator.

1796 unit + 299 browser, 18 Rust lib; clippy/tsc/dprint/eslint clean.

🤖 Generated with Claude Code

…ty from absent

Closes #366, #578.

## A file too large to show now says so (#366)

read_file_contents read whatever it was given. Everything downstream — the
Rust string, the JavaScript copy of it, the parsed rows — is held at once, so
a multi-gigabyte CSV took the renderer down before the user saw anything.

It now checks the size from the file's metadata and refuses before reading a
byte, naming the size, the limit and what to do instead. The cap is 256 MB,
chosen from what the pipeline survives rather than from disk.

The issue asks for streaming, which is the right long-term answer and a much
larger change: chunked reads, a chunked parse, and batched inserts driven by
the chunks. Refusing is not that. It is the part that stops the app dying,
and it is worth having whether or not streaming is built later.

Applied in the command rather than the dialog, so restore gets it too — it
reads whole files the same way.

## The file decides empty from absent (#578)

Every empty cell became SQL NULL. CSV distinguishes `,,` from `,"",` but
parseCSVLine discarded the quoting before anyone could act on it, so a NOT
NULL column rejected a row the user considered valid and a nullable one
silently stored NULL where the file said "".

The parser now reports which cells were written bare, alongside the rows
rather than changing their type, so every existing caller reads them
unchanged. A bare empty becomes NULL and a quoted one stays "". A row shorter
than its header is absent rather than empty, which is the same reading.

generateBatchInsert takes the flags as an optional argument and behaves as it
did without them.

## Two found while wiring it

setCsvBareEmpty could be handed undefined by a caller predating the field,
and the component then threw on .map when the import ran. Defaulted.

The import callback used the new state without listing it as a dependency, so
it would have closed over an empty array and treated every cell as absent —
the same shape as the grid's memo in #555. Caught by lint, which is what that
warning is for.

Three Rust tests on the limit, four on the parser, three on the generator.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 7b459db into main Sep 9, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/import-limits branch September 9, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][bug] CSV import has no row-size cap or file-size cap; parseCSV on 10 GB file hangs renderer

1 participant