kopia/kopia · error

unable to open object

Error message

unable to open object: %v

What it means

repositoryDirectory.loadLocked opens the directory's underlying object (rd.metadata.ObjectID) via repo.OpenObject to read its entries. This wrapped error means the repository blob backing the directory could not be opened — typically because the object does not exist, is unreadable, or the underlying blob storage failed.

Solutions

  1. Run `kopia repository verify` / `kopia blob list` to confirm the object exists
  2. Check storage backend connectivity and credentials (the wrapped error usually shows the real cause)
  3. Run `kopia maintenance run --full` and verify indexes are consistent
  4. Restore the directory from another snapshot if the object is genuinely missing
Defensive patterns

Strategy: retry

Validate before calling

// check connectivity/health of the repository before browsing
err := rep.Repository.Open(ctx)
if err != nil { return fmt.Errorf("repository unavailable: %w", err) }

Try / catch

err := dir.IterateEntries(ctx, cb)
if err != nil {
    if isTransient(err) { backoffAndRetry(ctx) } else { return fmt.Errorf("dir object %v unreadable: %w", oid, err) }
}

Prevention

When it happens

Trigger: Listing/iterating a directory in a mounted or browsed snapshot when ensureDirEntriesLoaded or ensureSummary triggers loadLocked and OpenObject fails for the directory's ObjectID (missing blob, storage backend error, corrupted/edited directory entry metadata).

Common situations: Repository maintained with a different/older tool version; blobs pruned or lost by faulty maintenance; cloud storage credentials/expiry causing OpenObject failures; corrupted directory object IDs after interrupted maintenance.

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


AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07). Data as JSON: /api/errors/cfbeeb43ee608a67. Report an issue: GitHub.

Appendix: source

Thrown at snapshot/snapshotfs/repofs.go:178

	return rd.loadLocked(ctx)
}

func (rd *repositoryDirectory) ensureSummary(ctx context.Context) error {
	rd.mu.Lock()
	defer rd.mu.Unlock()

	if rd.summary != nil {
		return nil
	}

	return rd.loadLocked(ctx)
}

func (rd *repositoryDirectory) loadLocked(ctx context.Context) error {
	r, err := rd.repo.OpenObject(ctx, rd.metadata.ObjectID)
	if err != nil {
		return errors.Wrapf(err, "unable to open object: %v", rd.metadata.ObjectID)
	}
	defer r.Close() //nolint:errcheck

	ent, summ, err := readDirEntries(r)
	if err != nil {
		return errors.Wrapf(err, "unable to read dir entries for: %v", rd.metadata.ObjectID)
	}

	for _, md := range ent {
		if md.Type == snapshot.EntryTypeDirectory && md.DirSummary != nil {
			md.FileSize = md.DirSummary.TotalFileSize
			md.ModTime = md.DirSummary.MaxModTime
		}
	}

	rd.summary = summ
	rd.dirEntries = map[string]*snapshot.DirEntry{}

View on GitHub (pinned to 82495e54b5)