Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 17, 2025

Description

Fixed transactWriteItems to properly handle ExpressionAttributeValues in Put operations. The function now only includes ExpressionAttributeValues when condition expressions actually contain values, preventing AWS SDK errors when the object is empty.

Changes:

  • Added conditional check before setting ExpressionAttributeValues in Put operations (lines 65-67)
  • Ensures consistency with Delete and Update operations which always set ExpressionAttributeValues
if (item.Put.conditions && item.Put.conditions.length > 0) {
  const conditionExpr = buildConditionExpressions(item.Put.conditions);
  putItem.ConditionExpression = conditionExpr.expression;
  putItem.ExpressionAttributeNames = conditionExpr.attrNames;
  if (Object.keys(conditionExpr.attrValues).length > 0) {
    putItem.ExpressionAttributeValues = conditionExpr.attrValues;
  }
}

Related Issues

Issue: #XXX

How Has This Been Tested

  • Existing test suite validates Put operations with and without conditions
  • Unit tests in transactWriteItems.spec.ts cover conditional Put scenarios
  • Verified TransactWriteCommand receives correctly formatted input

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Screenshots (if appropriate)

N/A


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix put operation in transaction write fix: correct the transaction write for put correctly. Nov 17, 2025
Copilot AI requested a review from snehithv November 17, 2025 02:46
Base automatically changed from fix/transaction-write-error to master November 17, 2025 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants