Skip to content

fix(restore): warn on snapshot backup errors#2262

Open
ousamabenyounes wants to merge 1 commit into
PlakarKorp:mainfrom
ousamabenyounes:fix/issue-1821-restore-warning
Open

fix(restore): warn on snapshot backup errors#2262
ousamabenyounes wants to merge 1 commit into
PlakarKorp:mainfrom
ousamabenyounes:fix/issue-1821-restore-warning

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jul 10, 2026

Copy link
Copy Markdown

What

Keep restore successful when the restore operation itself succeeds, but emit a warning when the source snapshot contains backup-time errors.

Closes #1821

Why

The issue discussion settled on warning the user instead of making restore fail for errors that happened during backup. This makes the restore result clearer without changing the exit status for successfully restored available files.

Test verification (RED -> GREEN)

Original issue repro on unmodified origin/main: create a plaintext repo, back up a tree as an unprivileged user with one unreadable file, then restore the resulting snapshot.

RED - upstream restore exits 0 and emits no restore warning even though the snapshot contains a backup error:

backup_exit=0
BACKUP_STDERR_START
042ce4be: KO ✘ /tmp/src1821/denied.txt: open /tmp/src1821/denied.txt: permission denied
BACKUP_STDERR_END
snapshot=042ce4be
restore_exit=0
RESTORE_STDOUT_START
042ce4be: OK ✓ /
042ce4be: OK ✓ /readable.txt
RESTORE_STDOUT_END
RESTORE_STDERR_START
RESTORE_STDERR_END

Full repro log: /tmp/see-real-bug_PlakarKorp-plakar_1821_confirmed.log.

GREEN - patched branch warns while preserving a successful restore:

ok github.com/PlakarKorp/plakar/subcommands/restore 0.211s

Secondary regression proof, after temporarily forcing the backup-error counter to return zero:

--- FAIL: TestRestoreWarnsWhenSnapshotContainsBackupErrors (0.20s)
    restore_extra_test.go:150:
        Error: "" does not contain "snapshot contains 1 backup error"
FAIL
FAIL github.com/PlakarKorp/plakar/subcommands/restore 0.222s

GREEN again after restoring the fix:

ok github.com/PlakarKorp/plakar/subcommands/restore 3.908s

Coverage added

  • Added a restore test that builds a snapshot containing a recorded backup error, restores it successfully, and asserts the warning is emitted.
  • The test now corresponds to the original issue behavior: backup-time errors are visible in the snapshot, but restore previously completed silently.

Test plan

  • docker run --rm -v "$PWD":/src -v /tmp/plakar-go-cache:/go/pkg/mod -v /tmp/plakar-go-build:/root/.cache/go-build -w /src golang:1.25 go test ./subcommands/restore -run TestRestoreWarnsWhenSnapshotContainsBackupErrors -count=1
  • docker run --rm -v "$PWD":/src -v /tmp/plakar-go-cache:/go/pkg/mod -v /tmp/plakar-go-build:/root/.cache/go-build -w /src golang:1.25 go test ./subcommands/restore -count=1
  • docker run --rm -v "$PWD":/src -v /tmp/plakar-go-cache:/go/pkg/mod -v /tmp/plakar-go-build:/root/.cache/go-build -w /src golang:1.25 sh -c 'go build -v ./... && go test ./...'

Full validation result:

exit:0
go build -v ./...: pass
go test ./...: pass

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.

Restore should fail if errors are reported in the snapshot

1 participant