paperclipai/paperclip · error

Failed to acquire environment lease

Error message

Failed to acquire environment lease

What it means

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.

Source

Thrown at server/src/services/environments.ts:1549

                  throw conflict(
                    "Reusable sandbox lease ownership changed during reacquisition.",
                  );
                }
                return reacquired;
              }
              return tx
                .insert(environmentLeases)
                .values(values)
                .returning()
                .then((rows) => rows[0] ?? null);
            })
          : await db
              .insert(environmentLeases)
              .values(values)
              .returning()
              .then((rows) => rows[0] ?? null);
      if (!row) {
        throw new Error("Failed to acquire environment lease");
      }
      return toEnvironmentLease(row);
    },

    releaseLease: async (
      id: string,
      status: Extract<EnvironmentLeaseStatus, "released" | "expired" | "failed" | "retained" | "pending_cleanup"> = "released",
      options?: {
        failureReason?: string;
        cleanupStatus?: EnvironmentLeaseCleanupStatus;
      },
    ) => {
      const now = new Date();
      const row = await db
        .update(environmentLeases)
        .set({
          status,
          releasedAt: status === "retained" ? null : now,

View on GitHub (pinned to 01ad858492)

Solutions

  1. Retry acquiring the environment lease; check for stale or exhausted leases if it persists.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at server/src/services/environments.ts:1395 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10). Data as JSON: /api/errors/d3997e2673f32bb2. Report an issue: GitHub.