Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS] DynamoDB UpdateItem return old values on ConditionalCheckFailedException #343

Open
Lorenzohidalgo opened this issue Jan 15, 2024 · 1 comment
Labels
pending triage Pending further investigation

Comments

@Lorenzohidalgo
Copy link

Lorenzohidalgo commented Jan 15, 2024

Docs state that one should be able to see that data by default on ctx.error.data, but this doesn't seem to be the case.

{
  "arguments": {
    "recordInput": {
      "id": "1",
      "sk": "1"
    }
  },
  "prev": {
    "result": {}
  },
  "stash": {},
  "error": {
    "message": "The conditional request failed (Service: DynamoDb, Status Code: 400, Request ID: 3S...)",
    "type": "DynamoDB:ConditionalCheckFailedException"
  },
  "outErrors": []
}

There is also no returnValuesOnConditionCheckFailure attribute for the UpdateItem operation allowed.

Actual response (where docs state we should also be able to see the old/current record values):

{
  "data": {
    "extendTtl": null
  },
  "errors": [
    {
      "path": [
        "extendTtl"
      ],
      "data": null,
      "errorType": null,
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "The conditional request failed (Service: DynamoDb, Status Code: 400, Request ID: 3S...)"
    }
  ]
}

With TransactWriteItems, where for some reason you can actually use returnValuesOnConditionCheckFailure for an UpdateItem operation, it seems to work as expected and the value is reachable in the ctx:

{
  "arguments": {
    "recordInput": {
      "id": "1",
      "sk": "1"
    }
  },
  "result": {
    "cancellationReasons": [
      {
        "type": "ConditionalCheckFailed",
        "message": "The conditional request failed",
        "item": {
          "test": {
            "test1": true
          },
          "sk": "1",
          "testField": "1-1",
          "id": "1",
          "ttl": 1705338604
        }
      }
    ]
  },
  "prev": {
    "result": {}
  },
  "stash": {},
  "error": {
    "message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed] (Service: DynamoDb, Status Code: 400, Request ID: OTL...)",
    "type": "DynamoDB:TransactionCanceledException"
  },
  "outErrors": []
}

But using TransactWriteItems isn't really an option, as it doesn't return all values of the updated record...

@onlybakam onlybakam added the pending triage Pending further investigation label Jan 16, 2024
@eriktim
Copy link

eriktim commented Jun 17, 2024

According to AWS support the docs are outdated and this field will not be present with APPSYNC_JS. I'm hoping for an official update here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending triage Pending further investigation
Projects
None yet
Development

No branches or pull requests

3 participants