{"record":{"id":"ee2977266702812f","repo":"kopia/kopia","slug":"unable-to-create-dir-rewriter","errorCode":null,"errorMessage":"unable to create dir rewriter","messagePattern":"unable to create dir rewriter","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_snapshot_fix.go","lineNumber":74,"sourceCode":"\tdefault:\n\t\treturn snapshotfs.RewriteFail\n\tcase invalidEntryStub:\n\t\treturn snapshotfs.RewriteAsStub(rep)\n\tcase invalidEntryRemove:\n\t\treturn snapshotfs.RewriteRemove\n\tcase invalidEntryKeep:\n\t\treturn snapshotfs.RewriteKeep\n\t}\n}\n\nfunc (c *commonRewriteSnapshots) rewriteMatchingSnapshots(ctx context.Context, rep repo.RepositoryWriter, rewrite snapshotfs.RewriteDirEntryCallback) error {\n\trw, err := snapshotfs.NewDirRewriter(ctx, rep, snapshotfs.DirRewriterOptions{\n\t\tParallel:               c.parallel,\n\t\tRewriteEntry:           rewrite,\n\t\tOnDirectoryReadFailure: failedEntryCallback(rep, c.invalidDirHandling),\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unable to create dir rewriter\")\n\t}\n\n\tdefer rw.Close(ctx)\n\n\tvar updatedSnapshots int\n\n\tmanifestIDs, err := c.listManifestIDs(ctx, rep)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanifests, err := snapshot.LoadSnapshots(ctx, rep, manifestIDs)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"error loading snapshots\")\n\t}\n\n\tfor _, mg := range snapshot.GroupBySource(manifests) {\n\t\tlog(ctx).Infof(\"Processing snapshot %v\", mg[0].Source)","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_snapshot_fix.go#L56-L92","documentation":"Wraps a failure from snapshotfs.NewDirRewriter, which builds the object used to rewrite directory entries inside snapshots. The error means the rewriter could not even be constructed, before any snapshot was processed. The original cause explains which internal prerequisite failed.","triggerScenarios":"Running `kopia snapshot fix <command>` (e.g. remove-invalid-files) with an invalid --parallel value or an invalid --invalid-directory-handling setting passed into DirRewriterOptions.","commonSituations":"Passing a non-positive or unparsable --parallel count, or an unsupported --invalid-directory-handling enum value.","solutions":["Check the wrapped cause for the invalid option value","Use a valid --parallel value (positive integer)","Use a supported --invalid-directory-handling value (e.g. fail, skip-all)","Re-run with default flags to confirm the command works without overrides"],"exampleFix":"// before\nkopia snapshot fix remove-invalid-files --parallel 0\n// after\nkopia snapshot fix remove-invalid-files --parallel 4","handlingStrategy":"validation","validationCode":"if parallel <= 0 {\n\treturn errors.New(\"--parallel must be a positive integer\")\n}\nif !validInvalidDirHandling(handling) {\n\treturn errors.Errorf(\"unsupported --invalid-directory-handling %v\", handling)\n}","typeGuard":null,"tryCatchPattern":"rw, err := snapshotfs.NewDirRewriter(ctx, rep, opts)\nif err != nil {\n\treturn errors.Wrap(err, \"dir rewriter setup failed\")\n}\ndefer rw.Close(ctx)","preventionTips":["Validate flag values (parallel count, handling enum) before running fix","Run the fix command with defaults first to isolate option problems","Keep kopia version consistent with the repository format"],"tags":["cli","snapshot","configuration","kopia"],"backgroundTag":"invalid-config-value","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"}