You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] JSON import: a stale preview can authorize committing a different file than the one the user reviewed #72
The import modal's dry-run preview is not tied to the file that produced it, so the classification
list the user approves can describe a different file than the one Run commits.
There is no request token or cancellation. parsed switches to the newly picked file immediately,
while plan is whatever preview resolves last. The Run button only checks that a plan exists
(:173), and commits parsed (:73):
voidcontroller.importCommit(mode,parsed)
Pick ledger A, then ledger B before A's /import/preview round-trip returns. If B resolves
first and A lands second, the modal shows B's filename with A's create/overwrite/invalid rows,
and Run commits B. In replace mode that is a whole-ledger swap justified by a preview the
reviewer never saw; the host writes a backup first, but the dry-run check — the entire point of the
preview step — is bypassed.
The same missing guard exists on file.text() (line 51): two quickly picked files can also be
parsed out of order and overwrite parsed/fileName.
How to reproduce
Open ⬆ Import and pick a ledger file A (a large file, or a LAN host where the preview takes
a moment).
Immediately pick ledger file B.
B's preview resolves first, A's resolves last → the stats/lists describe A while the filename
says B.
Press Run: importCommit receives B's payload.
This was reproduced with a jsdom render: two file picks, deferred importPreview promises resolved
B then A; the modal displayed b.json with A's plan rows and Run called importCommit with B.
Environment
dsh-taskboard 0.9.7 / dev @ fb97e7f (originally reproduced on 0.9.6 @ 3054eba)
DSH 0.2.1-rc.5, Windows 11, Node 26.13.0
Suggested fix
Capture a monotonic sequence in onFile (const seq = ++seqRef.current) and check it in both
async continuations (file.text() and importPreview), e.g. if (seq !== seqRef.current) return.
That is enough to drop every late response; the reset block at :44-50 already clears plan, so
the UI stays on "previewing" until the current file's preview lands. A regression test with two
deferred previews resolving out of order is cheap.
Dedupe
Nearest issues are #17 (import existing sessions) and #29 (bulk delete); neither covers the import
preview lifecycle. No open PR touches ImportModal.
Activity