Skip to content

fix(import): stop at the first failed statement, and say what already ran - #580

Merged
EVWorth merged 1 commit into
mainfrom
fix/import-stop-on-error
Sep 9, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/import-stop-on-error

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Closes #365.

The bug is the opposite of what the issue describes

The loop caught every error, counted it, and carried on to the end of the file:

} catch (e) {
  prog.errorCount++;
  prog.errors.push(`Statement ${i + 1}: …`);
}

So a dump whose CREATE TABLE failed still executed all of its INSERTs against whatever was already there. It didn't abort partway — it applied the whole file to a database in a state the file didn't expect.

The issue's repro says "with stopOnError=true (default)". There was no such option. The behaviour it assumed already existed is what this adds.

Stopping is now the default; the summary says where it stopped and how many statements had already applied. Continuing is a checkbox for when it's wanted — a file of independent INSERTs, say.

The proposed fix couldn't work

It asks for the run to be wrapped in a transaction with a full rollback. Two independent reasons that does nothing:

  1. DDL commits implicitly, and a dump is full of CREATE/DROP/ALTER. Verified earlier in this campaign: START TRANSACTION; ALTER TABLE …; ROLLBACK; leaves the change in place.
  2. Each statement goes through its own executeQuery, so each takes its own pooled connection. A START TRANSACTION sent in one call wouldn't cover the next — the transaction would silently apply to nothing.

So the UI says so rather than implying otherwise: statements that already ran stay applied either way, and files containing CREATE, DROP or ALTER cannot be rolled back. There's a test asserting that sentence is present — the temptation to promise atomicity here is exactly what the issue did.

Also

The checkbox has an aria-label. Its visible label wraps a second line of explanation, so the accessible name was the entire paragraph.

Tests

Four. Three fail against the previous version; the fourth asserts the rollback wording, which had nothing to fail against.

One existing browser test — "shows error count and error list" — now turns stopping off, because a list needs more than one error. Its intent is preserved rather than its assertion weakened.

1789 unit + 299 browser green; tsc/dprint/eslint clean.

Left in import

#366 (no row-size or file-size cap) and #578 (empty cell → NULL). Both need changes in csv-parser, so they pair naturally.

🤖 Generated with Claude Code

… ran

Closes #365.

The loop caught every error, counted it, and carried on to the end of the
file. A dump whose CREATE TABLE failed still executed all of its INSERTs
against whatever was already there — so the import did not abort partway, it
applied the whole file to a database in a state the file did not expect.

Stopping is now the default, and the summary says where it stopped and how
many statements had already applied. Continuing is a checkbox for the cases
where it is wanted — a file of independent INSERTs, say — and the existing
test for the error list opts into it, since a list needs more than one error.

The issue's repro describes "stopOnError=true (default)". There was no such
option; the behaviour it assumed already existed is what this adds.

## The proposed fix could not work

It asks for the run to be wrapped in a transaction with a full rollback on
error. Two independent reasons that does nothing:

DDL commits implicitly, and a dump is full of CREATE, DROP and ALTER.
Verified earlier in this campaign: START TRANSACTION, ALTER TABLE, ROLLBACK
leaves the change in place.

And each statement goes through its own executeQuery call, so each takes its
own pooled connection. A START TRANSACTION sent in one call would not cover
the next — the transaction would silently apply to nothing.

So the UI says so instead of implying otherwise: statements that already ran
stay applied either way, and files containing CREATE, DROP or ALTER cannot be
rolled back. A test asserts that sentence is present, because the temptation
to promise atomicity here is exactly what the issue did.

## Also

The checkbox has an aria-label. Its visible label wraps a second line of
explanation, so the accessible name was the whole paragraph.

Four tests. Three fail against the previous version; the fourth asserts the
rollback wording, which had nothing to fail against.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 33f7313 into main Sep 9, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/import-stop-on-error branch September 9, 2026 11:27
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] SQL import runs serially; one failed statement aborts rest when stopOnError=true

1 participant