{"id":18400908,"url":"https://github.com/magicmark/moto-issue-demo","last_synced_at":"2025-04-12T16:59:35.252Z","repository":{"id":69482156,"uuid":"501370559","full_name":"magicmark/moto-issue-demo","owner":"magicmark","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-08T19:00:11.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-16T03:24:48.244Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magicmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-08T18:40:47.000Z","updated_at":"2023-03-04T06:02:49.000Z","dependencies_parsed_at":"2023-03-15T22:00:37.773Z","dependency_job_id":null,"html_url":"https://github.com/magicmark/moto-issue-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fmoto-issue-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fmoto-issue-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fmoto-issue-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicmark%2Fmoto-issue-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicmark","download_url":"https://codeload.github.com/magicmark/moto-issue-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248602232,"owners_count":21131613,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T02:37:14.274Z","updated_at":"2025-04-12T16:59:35.214Z","avatar_url":"https://github.com/magicmark.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# moto-issue-demo\n\n### Repro instructions \n\n```bash\n$ git clone https://github.com/magicmark/moto-issue-demo.git\n$ cd moto-issue-demo\n$ poetry install\n$ poetry run pytest -vvv\n```\n\n### Output\n\n```\n        try:\n            order_breakfast()\n        except BaseException as err:\n\u003e           assert 'Item' in err.response[\"CancellationReasons\"][0]\nE           AssertionError: assert 'Item' in {'Code': 'ConditionalCheckFailed', 'Message': 'The conditional request failed'}\n\ntests/test_order_breakfast.py:40: AssertionError\n============================================================= short test summary info =============================================================\nFAILED tests/test_order_breakfast.py::test_breakfast_order - AssertionError: assert 'Item' in {'Code': 'ConditionalCheckFailed', 'Message': 'The...\n================================================================ 1 failed in 0.67s ================================================================\n```\n\n### What's the problem?\n\nWith DynamoDB+boto3, when a transaction fails due to a `ConditionExpression` failing,\nAND we've set `\"ReturnValuesOnConditionCheckFailure\": \"ALL_OLD\",` we should see the\ncurrent item in the error response.\n\nFor example, if we ran `order-breakfast` when hitting DynamoDB for real, here's the output\nof catching the exception and pprinting `err.reason`:\n\n```python\n{'CancellationReasons': [{'Code': 'ConditionalCheckFailed',\n                          'Item': {'customer': {'S': 'mark'},\n                                   'lock': {'M': {'acquired_at': {'N': '123'}}},\n                                   'mealtime': {'S': 'breakfast'}},\n                          'Message': 'The conditional request failed'}],\n 'Error': {'Code': 'TransactionCanceledException',\n           'Message': 'Transaction cancelled, please refer cancellation '\n                      'reasons for specific reasons [ConditionalCheckFailed]'},\n 'Message': 'Transaction cancelled, please refer cancellation reasons for '\n            'specific reasons [ConditionalCheckFailed]',\n 'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',\n                                      'content-length': '393',\n                                      'content-type': 'application/x-amz-json-1.0',\n                                      'date': 'Wed, 08 Jun 2022 18:55:51 GMT',\n                                      'server': 'Server',\n                                      'x-amz-crc32': '947576560',\n                                      'x-amzn-requestid': 'BDBL292TOK52OSPP0GTJTTS2CVVV4KQNSO5AEMVJF66Q9ASUAAJG'},\n                      'HTTPStatusCode': 400,\n                      'RequestId': 'BDBL292TOK52OSPP0GTJTTS2CVVV4KQNSO5AEMVJF66Q9ASUAAJG',\n                      'RetryAttempts': 0}}\n```\n\nNote that we see,`Code`, `Message`, and `Item`.\n\nUnder moto3, we do not see `Item`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicmark%2Fmoto-issue-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicmark%2Fmoto-issue-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicmark%2Fmoto-issue-demo/lists"}