{"record":{"id":"357311f7d95646cd","repo":"kopia/kopia","slug":"running-in-write-session","errorCode":null,"errorMessage":"running in write session","messagePattern":"running in write session","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/app.go","lineNumber":479,"sourceCode":"\t\t\treturn repo.WriteSession(ctx, rep, repo.WriteSessionOptions{\n\t\t\t\tPurpose:  \"cli:\" + c.currentActionName(),\n\t\t\t\tOnUpload: c.progress.UploadedBytes,\n\t\t\t}, act)\n\t\t})\n}\n\n// repositoryWriterActionWithMaintenance runs act in a write session and\n// may run opportunistic automatic maintenance on success. It should be used\n// only for operations that modify snapshot data such as snapshot create/delete.\nfunc (c *App) repositoryWriterActionWithMaintenance(act func(ctx context.Context, rw repo.RepositoryWriter) error) func(ctx *kingpin.ParseContext) error {\n\treturn c.repositoryAction(func(ctx context.Context, rep repo.Repository) error {\n\t\to := repo.WriteSessionOptions{\n\t\t\tPurpose:  \"cli:\" + c.currentActionName(),\n\t\t\tOnUpload: c.progress.UploadedBytes,\n\t\t}\n\n\t\tif err := repo.WriteSession(ctx, rep, o, act); err != nil {\n\t\t\treturn errors.Wrap(err, \"running in write session\")\n\t\t}\n\n\t\tif err := c.maybeRunMaintenance(ctx, rep); err != nil {\n\t\t\treturn errors.Wrap(err, \"running auto-maintenance\")\n\t\t}\n\n\t\treturn nil\n\t})\n}\n\nfunc (c *App) runAppWithContext(command *kingpin.CmdClause, cb func(ctx context.Context) error) error {\n\tctx := c.rootctx\n\n\tif c.loggerFactory != nil {\n\t\tctx = logging.WithLogger(ctx, c.loggerFactory)\n\t}\n\n\tfor _, r := range c.trackReleasable {","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/app.go#L461-L497","documentation":"Wrapper around repo.WriteSession failing while executing a CLI action inside a repository write session; the wrapped error carries the actual failure, which may be the action itself or the final flush.","triggerScenarios":"Thrown at cli/app.go:479 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the root cause.","Verify the repository is writable and the connection healthy, then retry the command."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}