{"record":{"id":"9f3668a61876feb4","repo":"paperclipai/paperclip","slug":"no-releaselease-destroylease-event-found-for-envir","errorCode":null,"errorMessage":"No releaseLease/destroyLease event found for environment ${environmentId}","messagePattern":"No releaseLease/destroyLease event found for environment (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sdk/src/testing.ts","lineNumber":273,"sourceCode":"      cursor++;\n    }\n  }\n  if (matched.length !== expectedOrder.length) {\n    throw new Error(\n      `Environment event order mismatch.\\nExpected: ${JSON.stringify(expectedOrder)}\\nActual:   ${JSON.stringify(actual)}`,\n    );\n  }\n}\n\n/** Assert that a full lease lifecycle (acquire → release) occurred for an environment. */\nexport function assertLeaseLifecycle(\n  events: EnvironmentEventRecord[],\n  environmentId: string,\n): { acquire: EnvironmentEventRecord; release: EnvironmentEventRecord } {\n  const acquire = events.find((e) => e.type === \"acquireLease\" && e.environmentId === environmentId);\n  const release = events.find((e) => (e.type === \"releaseLease\" || e.type === \"destroyLease\") && e.environmentId === environmentId);\n  if (!acquire) throw new Error(`No acquireLease event found for environment ${environmentId}`);\n  if (!release) throw new Error(`No releaseLease/destroyLease event found for environment ${environmentId}`);\n  if (acquire.timestamp > release.timestamp) {\n    throw new Error(`acquireLease occurred after release for environment ${environmentId}`);\n  }\n  return { acquire, release };\n}\n\n/** Assert that workspace realization occurred between lease acquire and release. */\nexport function assertWorkspaceRealizationLifecycle(\n  events: EnvironmentEventRecord[],\n  environmentId: string,\n): EnvironmentEventRecord {\n  const lifecycle = assertLeaseLifecycle(events, environmentId);\n  const realize = events.find(\n    (e) => e.type === \"realizeWorkspace\" && e.environmentId === environmentId,\n  );\n  if (!realize) throw new Error(`No realizeWorkspace event found for environment ${environmentId}`);\n  if (realize.timestamp < lifecycle.acquire.timestamp) {\n    throw new Error(`realizeWorkspace occurred before acquireLease for environment ${environmentId}`);","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/plugins/sdk/src/testing.ts#L255-L291","documentation":"Test-helper assertion in assertLeaseLifecycle: an acquireLease event exists but no matching 'releaseLease' or 'destroyLease' event was ever recorded for the environmentId. The plugin under test acquired a lease but never released or destroyed it, i.e. the lifecycle is incomplete or leaking the lease.","triggerScenarios":"Thrown at packages/plugins/sdk/src/testing.ts:273 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the lease is released/destroyed at the end of the environment lifecycle."],"exampleFix":null,"handlingStrategy":"validation","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"}