{"record":{"id":"d3997e2673f32bb2","repo":"paperclipai/paperclip","slug":"failed-to-acquire-environment-lease","errorCode":null,"errorMessage":"Failed to acquire environment lease","messagePattern":"Failed to acquire environment lease","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/environments.ts","lineNumber":1549,"sourceCode":"                  throw conflict(\n                    \"Reusable sandbox lease ownership changed during reacquisition.\",\n                  );\n                }\n                return reacquired;\n              }\n              return tx\n                .insert(environmentLeases)\n                .values(values)\n                .returning()\n                .then((rows) => rows[0] ?? null);\n            })\n          : await db\n              .insert(environmentLeases)\n              .values(values)\n              .returning()\n              .then((rows) => rows[0] ?? null);\n      if (!row) {\n        throw new Error(\"Failed to acquire environment lease\");\n      }\n      return toEnvironmentLease(row);\n    },\n\n    releaseLease: async (\n      id: string,\n      status: Extract<EnvironmentLeaseStatus, \"released\" | \"expired\" | \"failed\" | \"retained\" | \"pending_cleanup\"> = \"released\",\n      options?: {\n        failureReason?: string;\n        cleanupStatus?: EnvironmentLeaseCleanupStatus;\n      },\n    ) => {\n      const now = new Date();\n      const row = await db\n        .update(environmentLeases)\n        .set({\n          status,\n          releasedAt: status === \"retained\" ? null : now,","sourceCodeStart":1531,"sourceCodeEnd":1567,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/environments.ts#L1531-L1567","documentation":"Generic guard in the lease-acquisition service: inserting the environment_leases row (after company-binding checks) returned no row. The lease the caller asked for could not be created, so the acquisition path reports failure rather than continuing lease-less.","triggerScenarios":"Thrown at server/src/services/environments.ts:1395 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry acquiring the environment lease; check for stale or exhausted leases if it persists."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}