{"record":{"id":"89b694939b3bbfe5","repo":"paperclipai/paperclip","slug":"action-already-resolved","errorCode":"action_already_resolved","errorMessage":"Tool action request has already been resolved","messagePattern":"Tool action request has already been resolved","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":409,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":5488,"sourceCode":"      await tx.update(toolActionRequests).set({\n        status: \"failed\",\n        resolvedAt: now,\n        updatedAt: now,\n      }).where(and(\n        eq(toolActionRequests.id, input.actionRequestId),\n        eq(toolActionRequests.status, \"executing\"),\n        eq(toolActionRequests.updatedAt, input.claimUpdatedAt),\n      ));\n      return true;\n    });\n    if (!settled) return { reasonCode, message, settled: false };\n    await reflectToolActionInteractionLifecycle({\n      actionRequestId: input.actionRequestId,\n      status: \"failed\",\n      errorCode: reasonCode,\n      errorMessage: message,\n    });\n    return { reasonCode, message, settled: true };\n  }\n\n  async function expireApprovedActionForManagedArgumentDrift(input: {\n    actionRequestId: string;\n    invocationId: string;\n    toolName: string;\n    ownsExecutingClaim?: boolean;\n  }) {\n    const error = new ToolGatewayHttpError(\n      409,\n      \"Approved tool action managed arguments changed after review; request a new approval\",\n      \"approved_tool_managed_arguments_changed\",\n      { actionRequestId: input.actionRequestId, invocationId: input.invocationId, tool: input.toolName },\n    );\n    const now = new Date();\n    await options.beforeManagedArgumentDriftExpiry?.();\n    const [expired] = await db\n      .update(toolActionRequests)","sourceCodeStart":5470,"sourceCodeEnd":5506,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L5470-L5506","documentation":"Optimistic lock in the approve path: the status update ...where status=pending matched zero rows, so the action request was already resolved (approved/declined/expired) by someone else. The 409 tells the caller the request has already been resolved; re-read it to see the outcome.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:5320 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The request was already resolved. Do not resolve it twice; check its current status."],"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"}