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
restore panics instead of returning an error when a file cannot be written or a pack read fails #593
restore_contents (crates/core/src/commands/restore.rs) unwraps the results of destination writes and pack reads inside rayon worker closures. A file the destination cannot create or write, or a pack read that fails, panics a worker thread instead of returning an error. The caller loses the original error and every file not yet written. A host that does not catch the panic aborts.
Seen on rustic_core 0.13.0, and still present on main at 647d00f:
APFS refuses a file name that is not valid UTF-8 with EILSEQ (errno 92). A snapshot taken on Linux can hold such a name.
Write a snapshot holding a file named b"not-utf8-\xff". (We used Repository::archive with a ReadSource that renames one LocalSource entry and its Node.)
Restore it on macOS to an APFS folder with prepare_restore and restore.
prepare_restore succeeds. restore then panics in a worker:
thread '<unnamed>' panicked at rustic_core-0.13.0/src/commands/restore.rs:658:69:
called `Result::unwrap()` on an `Err` value: OpeningFileFailed(Os { code: 92, kind: Uncategorized, message: "Illegal byte sequence" })
The same happens for any file the destination refuses, for example a read-only folder or a full volume. Line 624 does the same for a pack read that fails partway, for example a dropped connection or a missing pack.
Expected
A failed write or read returns an error the caller can see, carrying the path and the source error. That lets the caller report it, as restic restore does: it names a file it cannot create and goes on with the rest. Returning it from restore would be enough, even if the restore then stops.
Context
We embed rustic_core in a library and run restore under catch_unwind. That keeps the host alive, but the error is gone by then. Our workarounds:
We filter names the destination cannot hold before calling prepare_restore.
We wrap the backend to keep the first failed pack read.
One more of the same kind in restore_contents, at restore.rs:643 on main: be.read_encrypted_from_partial(&read_data[start..end], bl.uncompressed_length).unwrap(). A pack whose bytes changed but kept their length fails its MAC check here and panics a worker. Returning that error would let a caller report it as damaged data instead of an unexpected stop.
Activity
stefanwichmann commentedon Oct 8, 2026
One more of the same kind in
restore_contents, atrestore.rs:643onmain:be.read_encrypted_from_partial(&read_data[start..end], bl.uncompressed_length).unwrap(). A pack whose bytes changed but kept their length fails its MAC check here and panics a worker. Returning that error would let a caller report it as damaged data instead of an unexpected stop.AlphaJack commentedon Oct 15, 2026
Also on Linux a restore over a read-only file panics at
restore.rs:658withEACCESas an unprivileged user:Output:
fix(restore): return errors from restoring file contents instead of p…