{"record":{"id":"8cbe2c34fec41da3","repo":"kopia/kopia","slug":"unable-to-get-snapshot-root-for-v","errorCode":null,"errorMessage":"unable to get snapshot root for %v","messagePattern":"unable to get snapshot root for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"snapshot/snapshotfs/snapshot_storage_stats.go","lineNumber":97,"sourceCode":"\n\t\t\treturn nil\n\t\t},\n\t})\n\tif twerr != nil {\n\t\treturn errors.Wrap(twerr, \"tree walker\")\n\t}\n\tdefer tw.Close(ctx)\n\n\tsrc := manifests[0].Source\n\n\tfor _, snap := range manifests {\n\t\t*unique = snapshot.StorageUsageDetails{}\n\n\t\trootName := src.String() + \"@\" + snap.StartTime.Format(time.RFC3339)\n\n\t\troot, err := SnapshotRoot(rep, snap)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"unable to get snapshot root for %v\", rootName)\n\t\t}\n\n\t\tif err := tw.Process(ctx, root, rootName); err != nil {\n\t\t\treturn errors.Wrapf(err, \"error processing %v\", rootName)\n\t\t}\n\n\t\tsnap.StorageStats = &snapshot.StorageStats{\n\t\t\tNewData:      *unique,\n\t\t\tRunningTotal: *runningTotal,\n\t\t}\n\n\t\tif err := callback(snap); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/snapshot/snapshotfs/snapshot_storage_stats.go#L79-L115","documentation":"CalculateStorageStats wraps a failure from SnapshotRoot(rep, snap) with \"unable to get snapshot root for %v\" where %v is \"source@startTime\". SnapshotRoot loads the root directory entry of a snapshot manifest from the repository object store; if the root object ID cannot be resolved or read, stats computation stops for the whole manifest list.","triggerScenarios":"Calling CalculateStorageStats with a manifest whose root object ID points to a missing/corrupted object, or whose RootEntry cannot be loaded (e.g. deleted or pruned underlying objects), causing SnapshotRoot to return an error.","commonSituations":"Repository corruption or blobs deleted by aggressive maintenance; a manifest from a different repository/store than the one passed in; partial restore/migration where the snapshot metadata exists but the referenced root object is gone.","solutions":["Inspect the wrapped error: if it is object-not-found for the root object, the snapshot is broken — remove it from the manifests slice and continue with the rest.","Run repository consistency tools (kopia repository verify / maintenance) to repair or prune damaged snapshots.","Confirm the manifests were produced from the same repo (rep) you pass in; mixing repos yields unresolvable root entries.","Guard the call: fetch SnapshotRoot yourself first and skip manifests whose root cannot be loaded instead of failing the entire batch."],"exampleFix":"// before\nerr := CalculateStorageStats(ctx, rep, allManifests, cb) // fails on one bad snapshot\n// after\nvar valid []*snapshot.Manifest\nfor _, m := range allManifests {\n    if _, err := SnapshotRoot(rep, m); err == nil {\n        valid = append(valid, m)\n    }\n}\nerr := CalculateStorageStats(ctx, rep, valid, cb)","handlingStrategy":"validation","validationCode":"for _, m := range manifests {\n    if _, err := SnapshotRoot(rep, m); err != nil {\n        return fmt.Errorf(\"snapshot %v has unreadable root: %w\", m.ID, err)\n    }\n}","typeGuard":"func hasRoot(rep repo.Repository, m *snapshot.Manifest) bool {\n    _, err := SnapshotRoot(rep, m)\n    return err == nil\n}","tryCatchPattern":"err := CalculateStorageStats(ctx, rep, manifests, cb)\nif err != nil && strings.Contains(err.Error(), \"unable to get snapshot root\") {\n    // skip/filter broken manifests and retry\n}","preventionTips":["Always pass manifests and repo from the same repository/config.","Run regular kopia maintenance to prevent object pruning of live snapshots.","Never manually delete blobs from the storage backend."],"tags":["kopia","snapshot","object-not-found","repo-corruption"],"backgroundTag":"resource-not-found","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}