Abort the run when packing fails, even under --skip-errors #185

Merged
clawbot merged 1 commits from issue-161-skip-errors-packing-failure into next 2026-09-22 12:28:44 +02:00
Collaborator

Fixes #161.

A chunk is registered as pending (known set, scanner-pending set, packer
pending-row list) before it is packed. Under --skip-errors the scanner
skipped a file on any processing error, including a failure inside
addChunkToPacker (packing, database, encryption, upload). The pending
chunk then stayed queued, and a later blob's finalize inserted it into the
chunks table with no blob_chunks row. The snapshot completed holding a
file whose chunk is in no blob; restore fails with "chunk not found in any
blob", and because loadKnownChunks reads the chunks table, later runs
treat the chunk as already stored.

Errors from addChunkToPacker are now wrapped in a marker type and abort
the run regardless of --skip-errors; only open and read errors are
skipped. The bookkeeping order is deliberately unchanged, since a finalize
triggered inside addChunkToPacker un-pends its own chunk. Flag help,
struct comments, and the README now say only unreadable files are skipped.

Tests: a one-time temp-file creation failure under --skip-errors now
aborts the run and leaves no chunk row without a blob (fails without this
change); a file read error under --skip-errors is still skipped and the
run completes, and aborts without the flag.

Disclosure (judgement call): I left the optional readability tweak in
packer.go (nil the current blob after cleanup on the handler-failure
path) out. Doing so would defeat the final Flush that fails an
interrupted-upload run, which is a separate safety net.

Model: opus-4-8

Fixes https://git.eeqj.de/sneak/vaultik/issues/161. A chunk is registered as pending (known set, scanner-pending set, packer pending-row list) before it is packed. Under `--skip-errors` the scanner skipped a file on any processing error, including a failure inside `addChunkToPacker` (packing, database, encryption, upload). The pending chunk then stayed queued, and a later blob's finalize inserted it into the `chunks` table with no `blob_chunks` row. The snapshot completed holding a file whose chunk is in no blob; restore fails with "chunk not found in any blob", and because `loadKnownChunks` reads the `chunks` table, later runs treat the chunk as already stored. Errors from `addChunkToPacker` are now wrapped in a marker type and abort the run regardless of `--skip-errors`; only open and read errors are skipped. The bookkeeping order is deliberately unchanged, since a finalize triggered inside `addChunkToPacker` un-pends its own chunk. Flag help, struct comments, and the README now say only unreadable files are skipped. Tests: a one-time temp-file creation failure under `--skip-errors` now aborts the run and leaves no chunk row without a blob (fails without this change); a file read error under `--skip-errors` is still skipped and the run completes, and aborts without the flag. Disclosure (judgement call): I left the optional readability tweak in `packer.go` (nil the current blob after cleanup on the handler-failure path) out. Doing so would defeat the final `Flush` that fails an interrupted-upload run, which is a separate safety net. Model: opus-4-8
clawbot added the needs-review label 2026-09-22 12:06:22 +02:00
clawbot self-assigned this 2026-09-22 12:06:22 +02:00
clawbot added 1 commit 2026-09-22 12:06:22 +02:00
A chunk is registered as pending (known, scanner-pending, packer
pending-row) before it is packed. Under --skip-errors the scanner
skipped a file on any processing error, including a failure inside
addChunkToPacker (packing, database, encryption, upload). The pending
chunk then stayed queued and a later blob's finalize inserted it into
the chunks table with no blob_chunks row, so a snapshot could complete
holding a file whose chunk is in no blob and cannot be restored.

Errors from addChunkToPacker are now marked and abort the run
regardless of --skip-errors; only open and read errors are skipped.
The bookkeeping order is unchanged (a finalize triggered inside
addChunkToPacker still un-pends its own chunk). Flag help and comments
now say only unreadable files are skipped.

Model: opus-4-8
Author
Collaborator

PASS

Model: opus-4-8

PASS Model: opus-4-8
clawbot merged commit b4654f8e52 into next 2026-09-22 12:28:44 +02:00
clawbot deleted branch issue-161-skip-errors-packing-failure 2026-09-22 12:28:44 +02:00
Sign in to join this conversation.