{"record":{"id":"28491b6578d9330d","repo":"rohitg00/ai-engineering-from-scratch","slug":"idempotency-key-was-reused-with-different-argument","errorCode":null,"errorMessage":"idempotency key was reused with different arguments","messagePattern":"idempotency key was reused with different arguments","errorType":"exception","errorClass":"ReliabilityError","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/29-mcp-reliability-cancellation-and-flow-control/code/main.py","lineNumber":352,"sourceCode":"        if cents <= 0:\n            raise ReliabilityError(\"charge must be positive\")\n        fingerprint = self._fingerprint(account, cents)\n        with self._lock:\n            self._connection.execute(\"BEGIN IMMEDIATE\")\n            try:\n                if idempotency_key is not None:\n                    stored = self._connection.execute(\n                        \"\"\"\n                        SELECT fingerprint, result_json\n                        FROM idempotency_records\n                        WHERE idempotency_key = ?\n                        \"\"\",\n                        (idempotency_key,),\n                    ).fetchone()\n                    if stored is not None:\n                        stored_fingerprint, stored_json = stored\n                        if stored_fingerprint != fingerprint:\n                            raise ReliabilityError(\n                                \"idempotency key was reused with different arguments\"\n                            )\n                        self._connection.execute(\"COMMIT\")\n                        return json.loads(stored_json)\n\n                row = self._connection.execute(\n                    \"SELECT executions FROM mutation_counter WHERE singleton = 1\"\n                ).fetchone()\n                if row is None:\n                    raise ReliabilityError(\"mutation counter is missing\")\n                execution_number = int(row[0]) + 1\n                result = {\n                    \"receipt\": f\"charge-{execution_number:03d}\",\n                    \"rpcId\": rpc_id,\n                    \"account\": account,\n                    \"cents\": cents,\n                }\n                result_json = json.dumps(","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/29-mcp-reliability-cancellation-and-flow-control/code/main.py#L334-L370","documentation":"Error \"idempotency key was reused with different arguments\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/29-mcp-reliability-cancellation-and-flow-control/code/main.py:352 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}