{"record":{"id":"ea06c78a03f5bbd0","repo":"paperclipai/paperclip","slug":"execution-workspace-was-reopened-and-cannot-be-arc","errorCode":null,"errorMessage":"Execution workspace was reopened and cannot be archived right now","messagePattern":"Execution workspace was reopened and cannot be archived right now","errorType":"http","errorClass":null,"httpStatus":409,"severity":"error","filePath":"server/src/routes/execution-workspaces.ts","lineNumber":1212,"sourceCode":"      // reopen-pending flag. The lock stops a concurrent reopen from publishing an\n      // active row between the status re-check and this archive write, so the\n      // destruction fence below never deletes a worktree that a reopen rebuilt.\n      const archiveResult = await svc.archiveWorkspaceUnderLifecycleLock({\n        id,\n        patch,\n        closedAt,\n      });\n      if (!archiveResult) {\n        res.status(404).json({ error: \"Execution workspace not found\" });\n        return;\n      }\n      if (archiveResult.outcome === \"reopen_pending\") {\n        // A reopen published this workspace as active while its source issue is\n        // still terminal. A caller will consume the rebuilt worktree. Refuse the\n        // archive and return before any lease teardown, runtime-service stop, or\n        // artifact cleanup, so the archive control never removes the rebuilt\n        // worktree during the reopen consumption window.\n        res.status(409).json({\n          error: \"Execution workspace was reopened and cannot be archived right now\",\n        });\n        return;\n      }\n      workspace = archiveResult.workspace;\n      const capturedGeneration = archiveResult.capturedGeneration;\n\n      // Closing the workspace ends the lane, so the runtime-control lease is released\n      // outright rather than waiting for owner-eligibility or TTL recovery.\n      await runtimeLeases.release({ executionWorkspaceId: existing.id, force: true });\n\n      if (existing.mode === \"shared_workspace\") {\n        await db\n          .update(issues)\n          .set({\n            executionWorkspaceId: null,\n            updatedAt: new Date(),\n          })","sourceCodeStart":1194,"sourceCodeEnd":1230,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/routes/execution-workspaces.ts#L1194-L1230","documentation":"archiveWorkspaceUnderLifecycleLock returned the reopen_pending outcome: a concurrent reopen published this workspace as active between the status re-check and the archive write, so this archive request is refused to avoid burying the reopened workspace.","triggerScenarios":"Thrown at server/src/routes/execution-workspaces.ts:780 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["This is an authorization rule, not a bug: perform the action with an actor that satisfies the stated constraint (board user, the owning agent, or an in-scope resource).","If access should be allowed, verify the actor's credentials/company scope and the resource's ownership before retrying."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}