aws / aws/aws-appsync-community

Runtime Error with transactWriteItems in AppSync JS Runtime on DynamoDB Versioned Data Source

Open
#340 2 comments 5 reactions 0 assignees View on GitHub
pending triage
Dominant language
HTML
Stars
507
Forks
37
PR merge metrics
No merged PRs in 30d

Description

I am experiencing a runtime error when using the transactWriteItems operation in the AppSync JavaScript runtime, specifically with a DynamoDB data source that has the versioning feature enabled. The same code operates correctly on a data source where versioning is not enabled.

Interestingly, the transactGetItems operation functions as expected in both environments. This makes sense as the GetItem operation is not affected by the versioning feature.

I have not found any documentation stating that the transactWriteItems operation is incompatible with versioned DynamoDB data sources. Therefore, I am reporting this issue for further investigation.

### Steps to Reproduce
1. example appsync schema:
```graphql
type Mutation {
test(t: String): Boolean
}

schema {
mutation: Mutation
}
```

2. example resolver function:
```javascript
export function request(ctx) {
const { t } = ctx.args;

return {
version: '2018-05-29',
operation: 'TransactWriteItems',
transactItems: [{
table: 'test',
operation: 'PutItem',
key: util.dynamodb.toMapValues({ pk: "a", sk: "b"}),
attributeValues: util.dynamodb.toMapValues({ hello: "world!", text: t }),
}, {
table: 'test',
operation: 'PutItem',
key: util.dynamodb.toMapValues({ pk: "a", sk: "c"}),
attributeValues: util.dynamodb.toMapValues({ hello: "world!", text: t }),
}],
};
}

export function response(ctx) {
console.log(ctx.result);
return true;
}
```

3. query
```graphql
mutation Test {
test(t: "Hello")
}
```

4. error:
```json
{
"data": {
"test": null
},
"errors": [
{
"path": [
"test"
],
"data": null,
"errorType": "Code",
"errorInfo": null,
"locations": [
{
"line": 64,
"column": 3,
"sourceName": null
}
],
"message": "Runtime Error"
}
]
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the example AppSync schema and JavaScript resolver in the issue, then run the Test mutation against versioned and non-versioned DynamoDB data sources. Compare the TransactWriteItems request and Runtime Error with the working TransactGetItems case. Done means identifying the compatibility cause and documenting or confirming the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql, javascript
Domain
api, backend, cloud, database
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.