paperclipai/paperclip · error · EnvironmentRunError

lease_acquire_failed

lease_acquire_failed

Error message

Failed to acquire lease for environment "${input.environment.name}" (${input.environment.driver}): ${err instanceof Error ? err.message : String(err)}

What it means

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.

Source

Thrown at server/src/services/environment-run-orchestrator.ts:214

  /**
   * Acquire an environment lease for a heartbeat run.
   * Wraps the runtime driver's acquire call with standardized error handling.
   */
  async function acquireLease(input: {
    companyId: string;
    environment: Environment;
    issueId: string | null;
    agentId: string;
    heartbeatRunId: string;
    persistedExecutionWorkspace: Pick<ExecutionWorkspace, "id" | "mode"> | null;
    executionWorkspaceSettings: IssueExecutionWorkspaceSettings | null;
    adapterType: string | null;
  }): Promise<EnvironmentRuntimeLeaseRecord> {
    try {
      return await environmentRuntime.acquireRunLease(input);
    } catch (err) {
      throw new EnvironmentRunError(
        "lease_acquire_failed",
        `Failed to acquire lease for environment "${input.environment.name}" (${input.environment.driver}): ${err instanceof Error ? err.message : String(err)}`,
        {
          environmentId: input.environment.id,
          driver: input.environment.driver,
          cause: err,
        },
      );
    }
  }

  /**
   * Resolve the execution transport for an adapter based on the acquired lease.
   */
  async function resolveTransport(input: {
    companyId: string;
    adapterType: string;
    environment: Environment;

View on GitHub (pinned to 120ae5428f)

Solutions

  1. Investigate the lease acquisition failure in the message (provider capacity, stale lease), then retry.
  2. Release stale leases for the environment if none are actively in use.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at server/src/services/environment-run-orchestrator.ts:214 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/320e0ed1566dd6ee. Report an issue: GitHub.