{"record":{"id":"562abca64fe5bd15","repo":"kopia/kopia","slug":"operation-supported-only-on-direct-repository","errorCode":null,"errorMessage":"operation supported only on direct repository","messagePattern":"operation supported only on direct repository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli/app.go","lineNumber":428,"sourceCode":"\t\t}\n\n\t\treturn c.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {\n\t\t\treturn act(ctx, apiClient)\n\t\t})\n\t}\n}\n\nfunc assertDirectRepository(act func(ctx context.Context, rep repo.DirectRepository) error) func(ctx context.Context, rep repo.Repository) error {\n\treturn func(ctx context.Context, rep repo.Repository) error {\n\t\tif rep == nil {\n\t\t\treturn act(ctx, nil)\n\t\t}\n\n\t\t// right now this assertion never fails,\n\t\t// but will fail in the future when we have remote repository implementation\n\t\tlr, ok := rep.(repo.DirectRepository)\n\t\tif !ok {\n\t\t\treturn errors.New(\"operation supported only on direct repository\")\n\t\t}\n\n\t\treturn act(ctx, lr)\n\t}\n}\n\nfunc (c *App) directRepositoryWriteAction(act func(ctx context.Context, rep repo.DirectRepositoryWriter) error) func(ctx *kingpin.ParseContext) error {\n\treturn c.repositoryAction(assertDirectRepository(func(ctx context.Context, rep repo.DirectRepository) error {\n\t\trep.LogManager().Enable()\n\n\t\treturn repo.DirectWriteSession(ctx, rep, repo.WriteSessionOptions{\n\t\t\tPurpose:  \"cli:\" + c.currentActionName(),\n\t\t\tOnUpload: c.progress.UploadedBytes,\n\t\t}, act)\n\t}))\n}\n\nfunc (c *App) directRepositoryReadAction(act func(ctx context.Context, rep repo.DirectRepository) error) func(ctx *kingpin.ParseContext) error {","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/app.go#L410-L446","documentation":"attemptReadPackFileLocalIndex reads a section of a pack blob that supposedly contains the pack-local index, using sm.st.GetBlob with the pack file ID, offset and length. If GetBlob fails, the error is wrapped as \"error getting blob %v\" naming the pack file. This is the optimized-read path that tries to use each pack's embedded local index before falling back to the shared index.","triggerScenarios":"readPackFileLocalIndex attempts the optimized path for a pack file whose blob cannot be fetched: blob missing from storage, network/backend error, or insufficient permissions during GetBlob(packFile, offset, length).","commonSituations":"Pack file garbage-collected or deleted by maintenance in another client; transient S3/network failure; eventually-consistent backend not yet showing a newly uploaded pack; corrupted provider credentials.","solutions":["Retry the operation — callers (readPackFileLocalIndex) fall back to the non-optimized index path, so transient errors are usually harmless.","Check that the pack blob exists in the storage backend and that connectivity/credentials are valid.","Run kopia maintenance (compact + garbage collection) to reconcile index state with actual blobs."],"exampleFix":"// before\nif err := readPackFileLocalIndex(ctx, packFile); err != nil {\n\treturn err // optimized-read failure aborts\n}\n// after\nif err := readPackFileLocalIndex(ctx, packFile); err != nil {\n\tlog.Debugf(\"optimized local-index read failed for %v: %v; falling back\", packFile, err)\n\treturn loadFromSharedIndex(ctx, packFile) // graceful fallback\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := readPackFileLocalIndex(ctx, packFile); err != nil {\n\t// optimized path is best-effort: log and fall back to shared index\n\tlog.Debugf(\"local index read failed: %v\", err)\n\treturn sm.loadFromSharedIndex(ctx, packFile)\n}","preventionTips":["Treat the optimized local-index path as best-effort; always have the shared-index fallback wired in.","Avoid deleting pack blobs outside of kopia-managed garbage collection.","Use strongly consistent storage when possible to reduce partial-read surprises."],"tags":["blob-storage","pack-file","network"],"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"}