{"record":{"id":"8a180db28c91659e","repo":"paperclipai/paperclip","slug":"managed-sandbox-environment-changed-during-reconci","errorCode":null,"errorMessage":"Managed sandbox environment changed during reconciliation","messagePattern":"Managed sandbox environment changed during reconciliation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/environments.ts","lineNumber":651,"sourceCode":"          };\n        }\n\n        const updated = await tx\n          .update(environments)\n          .set({\n            name: desiredName,\n            description: input.description ?? null,\n            config: desiredConfig,\n            metadata: withoutManagedEnvironmentArchiveToken(\n              mergeManagedEnvironmentMetadata(row.metadata, desiredMetadata, keys),\n            ),\n            status: \"active\",\n            updatedAt: new Date(),\n          })\n          .where(eq(environments.id, row.id))\n          .returning()\n          .then((rows) => rows[0] ?? null);\n        if (!updated) throw new Error(\"Managed sandbox environment changed during reconciliation\");\n        await writeBindings(\n          updated.id,\n          input.stockVersion ?? MANAGED_ENVIRONMENT_STOCK_VERSION,\n          latestStockHash,\n          desiredStock,\n          true,\n        );\n        return {\n          environment: toEnvironment(updated),\n          action: \"updated\",\n          stockStatus,\n          updateAvailable: false,\n          stockHash: latestStockHash,\n        };\n      },\n    );\n    if (reconciliation.action !== \"unchanged\" || trackingInitialized) {\n      const action = reconciliation.action === \"added\"","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/environments.ts#L633-L669","documentation":"Concurrency guard in ensureManagedSandboxEnvironment's update path: the targeted row's UPDATE ... RETURNING produced no row, meaning it disappeared or was modified by a concurrent transaction mid-reconciliation. Fails instead of assuming the environment is in the desired state.","triggerScenarios":"Thrown at server/src/services/environments.ts:651 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the reconciliation; the environment changed concurrently. Investigate concurrent modifications if it persists."],"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-14T05:17:10.506Z"}