Skip to content

Refreshing a table after a column was removed no longer blocks other tables - #653

Merged
MerciHanrim merged 1 commit into
mainfrom
refresh-undecided-row-removed-columns
Nov 23, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
refresh-undecided-row-removed-columns

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #619 (item 3 only; items 4, 1 and 5 stay for their own scopes).

What was wrong

Data ▸ Refresh with a column confirmed as removed, while a row missing from the new data is left undecided (neither unlinked nor deleted, the wizard's default):

  • The commit copied the undecided row whole, so it kept its value for the removed column: number, label or foreign key alike.
  • The stored table then no longer matched its read-back (the reader drops a value under a column the table does not have).
  • A refresh of any other table of the document checks the whole batch by that read-back, and was refused with round-trip-mismatch ("This data could not be stored safely"), however good its data.
  • It lasted until Undo of the refresh or a reopen: the saved file held the value, and opening it dropped it, with the same revision digest.

docs/data-import.md ("Column-level events") already says a removed column's prior values are dropped; the undecided branch of buildRefreshCommit did not follow it.

The change

  • src/model/dataImportRefresh.ts: the undecided missing row carries over only the values under a column the refreshed table keeps, with the same role. Values under a kept column stay: they are the base of the Parameters still linked to the row.
  • docs/data-import.md: one paragraph under "Column-level events" naming the undecided row.
  • Not in this PR, as agreed: files saved before (cleaned on open, no digest change) and the first-import path (it checks only the new tables; read, not run).

Tests (src/model/dataImportRefresh.test.ts), written first

Tables Items (key, name = label, weight and cost = number, cat = foreign key to Cats) and Cats; Parameters on both Items rows' weight and cost; the paste holds only itm_b, so itm_a is missing and left undecided.

Test On main's code With the fix
weight (number) removed: row itm_a, read-back, refresh of Cats col_weight: 10 kept, read-back differs, Cats refused { col_cost: 4 }, equal, Cats passes
name (label) removed: the same label kept, Cats refused label gone, Cats passes
cat (foreign key) removed: the same foreign key kept, Cats refused foreign key gone, Cats passes
saved and read back: file row, reopened tables, refresh of Cats file row holds col_weight, reopened differs file row { col_cost: 4 }, reopened equal, Cats passes
kept cost: value 4, Parameter still linked; weight's Parameters unlinked pass pass
control: no column removed, row carried whole pass pass
control: row unlinked, or deleted pass pass

On main's code 4 of the 7 fail. The kept-cost test first failed on my own assertion: it expected the cost Parameter to be absent from the changed nodes, but its auto-composed label is recomputed. It now checks that the Parameter stays linked to cost with value 4. Run A-unit-on-main-code.out is that first run, kept; A2 is the rerun.

The measurement before the fix (kept as run, with what was withdrawn)

The reproduction probe went through the store's own commit, Undo, the save writer and the reader.

  • Run 1 is withdrawn whole: the probe passed header row index 0 (the index is 1-based), so every refresh was refused at validation and nothing was committed.
  • Run 2 is withdrawn for one field only: fileHasStray tested the saved text with a regex that does not match the indented JSON, so its false means nothing. Its other values stand and are the same in run 3.
  • Run 3 parses the saved file. Its row itm_a holds col_weight: 10.

Run 3 also measured:

  • Undo of the refresh lets the other table refresh again.
  • Unlink, delete, or no column removed leave nothing behind.

Checks

  • npx tsc -b: clean.
  • npm run lint: 88 warnings, the baseline.
  • All check:* scripts: pass.
  • Unit suite: 5735 passed, 4 skipped.
  • Related e2e, one worker, no retries: e2e/data-import-refresh.spec.ts and e2e/data-import-refresh-errors.spec.ts, 15 passed. They hold no screenshot comparisons.

What it touches

Only the commit of a refresh with a removed column and an undecided missing row. A refresh without a removed column, an unlinked or deleted row, and every other path are unchanged.

…tables

A missing row left undecided on a refresh carries over only the values of the columns the refreshed table keeps, with the same role. Copied whole, it kept a removed column's value, the stored table no longer matched its read-back, and the batch-wide round-trip gate refused the next refresh of every other table. Part of #619.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 23, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: b949a26
Status: ✅  Deploy successful!
Preview URL: https://9d7ade63.cozy-loop-studio.pages.dev
Branch Preview URL: https://refresh-undecided-row-remove.cozy-loop-studio.pages.dev

View logs

@MerciHanrim
MerciHanrim merged commit dca35c0 into main Nov 23, 2026
13 checks passed
@MerciHanrim
MerciHanrim deleted the refresh-undecided-row-removed-columns branch November 23, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant