{"record":{"id":"320e0ed1566dd6ee","repo":"paperclipai/paperclip","slug":"lease-acquire-failed","errorCode":"lease_acquire_failed","errorMessage":"Failed to acquire lease for environment \"${input.environment.name}\" (${input.environment.driver}): ${err instanceof Error ? err.message : String(err)}","messagePattern":"Failed to acquire lease for environment \"(.+?)\" \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"EnvironmentRunError","httpStatus":null,"severity":"error","filePath":"server/src/services/environment-run-orchestrator.ts","lineNumber":214,"sourceCode":"\n  /**\n   * Acquire an environment lease for a heartbeat run.\n   * Wraps the runtime driver's acquire call with standardized error handling.\n   */\n  async function acquireLease(input: {\n    companyId: string;\n    environment: Environment;\n    issueId: string | null;\n    agentId: string;\n    heartbeatRunId: string;\n    persistedExecutionWorkspace: Pick<ExecutionWorkspace, \"id\" | \"mode\"> | null;\n    executionWorkspaceSettings: IssueExecutionWorkspaceSettings | null;\n    adapterType: string | null;\n  }): Promise<EnvironmentRuntimeLeaseRecord> {\n    try {\n      return await environmentRuntime.acquireRunLease(input);\n    } catch (err) {\n      throw new EnvironmentRunError(\n        \"lease_acquire_failed\",\n        `Failed to acquire lease for environment \"${input.environment.name}\" (${input.environment.driver}): ${err instanceof Error ? err.message : String(err)}`,\n        {\n          environmentId: input.environment.id,\n          driver: input.environment.driver,\n          cause: err,\n        },\n      );\n    }\n  }\n\n  /**\n   * Resolve the execution transport for an adapter based on the acquired lease.\n   */\n  async function resolveTransport(input: {\n    companyId: string;\n    adapterType: string;\n    environment: Environment;","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/server/src/services/environment-run-orchestrator.ts#L196-L232","documentation":"EnvironmentRunError wrapper around environmentRuntime.acquire: the runtime driver threw while trying to acquire an execution lease for this heartbeat run. The underlying driver error message is embedded so the failure reason (capacity, provider error, etc.) is preserved for the run record.","triggerScenarios":"Thrown at server/src/services/environment-run-orchestrator.ts:214 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Investigate the lease acquisition failure in the message (provider capacity, stale lease), then retry.","Release stale leases for the environment if none are actively in use."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}