kopia/kopia · error · ErrSnapshotNotFound
snapshot not found
Error message
snapshot not found
What it means
ErrSnapshotNotFound is the sentinel error snapshot.LoadSnapshot and related APIs return when no snapshot manifest exists for the requested ID or root object ID. It is exported so callers can branch on it with errors.Is instead of string matching.
Solutions
- List existing snapshots with 'kopia snapshot list' and use an ID from that output
- Check errors.Is(err, snapshot.ErrSnapshotNotFound) in your caller and treat it as an expected, non-fatal case (as command_snapshot_delete.go does)
- Verify you are connected to the repository that actually owns the snapshot
- If the ID is a root object ID, use FindSnapshotByRootObjectIDOrManifestID instead of assuming a manifest ID
Example fix
// before
if _, err := snapshot.LoadSnapshot(ctx, rep, id); err != nil {
return err
}
// after
if _, err := snapshot.LoadSnapshot(ctx, rep, id); err != nil {
if errors.Is(err, snapshot.ErrSnapshotNotFound) {
return nil // nothing to do
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
ids, err := snapshot.ListSnapshotManifests(ctx, rep, nil, true) // keep a set of valid manifest IDs and check membership before LoadSnapshot
Try / catch
_, err := snapshot.LoadSnapshot(ctx, rep, id)
if errors.Is(err, snapshot.ErrSnapshotNotFound) {
// expected case: skip or report 'not found'
} else if err != nil {
return err
} Prevention
- Always branch on errors.Is(err, snapshot.ErrSnapshotNotFound) rather than err != nil
- Cross-check snapshot IDs against 'kopia snapshot list' output
- Remember snapshots may have been deleted concurrently by another client
When it happens
Trigger: Calling LoadSnapshot with a manifest ID that does not exist, or CLI commands (snapshot delete/pin/restore) with an ID that is not a snapshot; run() and TestSnapshotsAPI surface it when looking up stale or mistyped snapshot IDs.
Common situations: Deleting or pinning a snapshot ID from a different repository; an ID that refers to a non-snapshot manifest; a snapshot already deleted by another client; copy-pasting an object ID instead of a manifest ID.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- failed to get snapshot manifest for the given snapshotID
- unable to load snapshot
- cannot save manifest
- error loading snapshot
- error loading snapshots
AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07).
Data as JSON: /api/errors/104e6cda5623d80a.
Report an issue: GitHub.
Appendix: source
Thrown at snapshot/manager.go:28
"github.com/kopia/kopia/fs"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/logging"
"github.com/kopia/kopia/repo/manifest"
"github.com/kopia/kopia/repo/object"
)
// ManifestType is the value of the "type" label for snapshot manifests.
const ManifestType = "snapshot"
// Manifest labels identifying snapshots.
const (
UsernameLabel = "username"
HostnameLabel = "hostname"
PathLabel = "path"
)
// ErrSnapshotNotFound is returned when a snapshot is not found.
var ErrSnapshotNotFound = errors.New("snapshot not found")
const (
typeKey = manifest.TypeLabelKey
loadSnapshotsConcurrency = 50 // number of snapshots to load in parallel
)
var log = logging.Module("kopia/snapshot")
// ListSources lists all snapshot sources in a given repository.
func ListSources(ctx context.Context, rep repo.Repository) ([]SourceInfo, error) {
items, err := rep.FindManifests(ctx, map[string]string{
typeKey: ManifestType,
})
if err != nil {
return nil, errors.Wrap(err, "unable to find manifest entries")
}
View on GitHub (pinned to 82495e54b5)