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

Moto allows empty ExpressionAttributeValues in transaction put item #8405

Closed
regoawt opened this issue Dec 16, 2024 · 1 comment · Fixed by #8443
Closed

Moto allows empty ExpressionAttributeValues in transaction put item #8405

regoawt opened this issue Dec 16, 2024 · 1 comment · Fixed by #8443

Comments

@regoawt
Copy link

regoawt commented Dec 16, 2024

Hi,

Transact write items fails with An error occurred (ValidationException) when calling the TransactWriteItems operation: ExpressionAttributeValues must not be empty when making the request against DDB, but moto allows it:

[
  {
    "Update": {
      "Key": { "pk": { "S": "globals" }, "sk": { "S": "globals" } },
      "UpdateExpression": "SET #0 = :0",
      "ExpressionAttributeNames": { "#0": "tenant_count" },
      "ExpressionAttributeValues": { ":0": { "N": "1" } },
      "TableName": "Table1"
    }
  },
  {
    "Put": {
      "Item": { "pk": { "S": "tenant#0000001-tenant#0000001" }, "sk": { "S": "tenant#0000001" } },
      "ConditionExpression": "attribute_not_exists(#n0)",
      "TableName": "Table1",
      "ExpressionAttributeNames": { "#n0": "pk" },
      "ExpressionAttributeValues": {}
    }
  }
]

The Update operation works fine but the Put should raise an error.

@bblommers
Copy link
Collaborator

Hi @regoawt, thank you for raising this, and welcome to Moto! I've opened a PR that adds validation for this scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants