{"record":{"id":"5fa22737247877fe","repo":"paperclipai/paperclip","slug":"sandbox-provider-input-provider-leaked-lease","errorCode":null,"errorMessage":"Sandbox provider \"${input.provider}\" leaked lease \"${input.providerLeaseId ?? \"unknown\"}\": the acquire could not tear it down and could not record a durable pending-cleanup row. The live sandbox has no durable cleanup state and needs a manual teardown.","messagePattern":"Sandbox provider \"(.+?)\" leaked lease \"(.+?)\": the acquire could not tear it down and could not record a durable pending-cleanup row\\. The live sandbox has no durable cleanup state and needs a manual teardown\\.","errorType":"exception","errorClass":"SandboxOrphanCleanupWriteError","httpStatus":null,"severity":"error","filePath":"server/src/services/environment-runtime.ts","lineNumber":1381,"sourceCode":"          issueId: record.issueId,\n          heartbeatRunId: record.heartbeatRunId,\n          provider: record.provider,\n          providerLeaseId: record.providerLeaseId,\n          metadata: record.metadata,\n          failureReason: DEFERRED_ORPHAN_CLEANUP_FAILURE_REASON,\n        });\n        // The durable row exists now, so the sweep finds and releases the orphan.\n        // Drop the spooled copy only after the row lands. A crash between the two\n        // leaves the spooled copy for a later flush, which re-inserts a duplicate\n        // the idempotent teardown handles. This order never loses the orphan.\n        await orphanCleanupSpool.remove(record);\n        recovered += 1;\n      } catch {\n        // The database is still down. Re-queue the record for a later flush,\n        // unless the buffer filled again. The identifiers carry no secret; the\n        // caught write exception never enters the log, because it can hold a\n        // credential in its message, code, cause, or stack.\n        const requeued = enqueueDeferredOrphanCleanup(record);\n        logger.warn(\n          {\n            errorKind: SANDBOX_ORPHAN_CLEANUP_WRITE_ERROR_KIND,\n            provider: record.provider,\n            providerLeaseId: record.providerLeaseId,\n            companyId: record.companyId,\n            environmentId: record.environmentId,\n            requeued,\n          },\n          requeued\n            ? \"deferred sandbox orphan cleanup flush failed; kept the orphan buffered for a later flush\"\n            : \"deferred sandbox orphan cleanup flush failed and the in-process buffer is full; live sandbox needs a manual teardown\",\n        );\n      }\n    }\n    return { recovered, pending: deferredOrphanCleanups.length };\n  };\n","sourceCodeStart":1363,"sourceCodeEnd":1399,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/environment-runtime.ts#L1363-L1399","documentation":"Error \"Sandbox provider \"${input.provider}\" leaked lease \"${input.providerLeaseId ?? \"unknown\"}\": the acquire could not tear it down and could not record a durable pending-cleanup row. The live sandbox has no durable cleanup state and needs a manual teardown.\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at server/src/services/environment-runtime.ts:1259 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Manually tear down the leaked sandbox using the provider lease id in the message, then repair the cleanup row state."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}