{"record":{"id":"cec3a51d9f39f205","repo":"paperclipai/paperclip","slug":"execution-workspace-cannot-be-closed-right-now","errorCode":null,"errorMessage":"Execution workspace cannot be closed right now","messagePattern":"Execution workspace cannot be closed right now","errorType":"http","errorClass":null,"httpStatus":409,"severity":"error","filePath":"server/src/routes/execution-workspaces.ts","lineNumber":1184,"sourceCode":"      patch.metadata = req.body.config === undefined\n        ? requestedMetadata\n        : mergeExecutionWorkspaceConfig(requestedMetadata, req.body.config ?? null);\n    }\n    let workspace = existing;\n    let cleanupWarnings: string[] = [];\n    const configForCleanup = readExecutionWorkspaceConfig(\n      ((patch.metadata as Record<string, unknown> | null | undefined) ?? (existing.metadata as Record<string, unknown> | null)) ?? null,\n    );\n\n    if (req.body.status === \"archived\" && existing.status !== \"archived\") {\n      const readiness = await svc.getCloseReadiness(existing.id);\n      if (!readiness) {\n        res.status(404).json({ error: \"Execution workspace not found\" });\n        return;\n      }\n\n      if (readiness.state === \"blocked\") {\n        res.status(409).json({\n          error: readiness.blockingReasons[0] ?? \"Execution workspace cannot be closed right now\",\n          closeReadiness: readiness,\n        });\n        return;\n      }\n\n      const closedAt = new Date();\n      // Archive under the per-workspace lifecycle lock. The service takes the same\n      // lock as a reopen, raises the lifecycle generation, and clears the\n      // 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) {","sourceCodeStart":1166,"sourceCodeEnd":1202,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/routes/execution-workspaces.ts#L1166-L1202","documentation":"The archive request reached the close-readiness gate and readiness reported the workspace is not closable right now (e.g. live runtime services, pending operations), so the transition to archived is refused.","triggerScenarios":"Thrown at server/src/routes/execution-workspaces.ts:752 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":"validation","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-14T00:17:10.932Z"}