aws / aws/aws-appsync-community
How to detect mapping template error in logs
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
Is there a way to see in the cloudwatch logs for appsync any messages that are from a mapping template error?
We have all the logs turned on for AppSync.
The response received by the consumer was
```
{
"data": null,
"errors": [
{
"path": [
"mutationThatWasCalled"
],
"data": null,
"errorType": "MappingTemplate",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "Unable to convert \n \n \n \n\n # This is a comment in the response template that had only one pound sign in front rather than two and so resulted in an error\n \n to Object."
}
]
}
```
The only log we can find that hints that this error is going to occur is this one
```
fieldInError 0
fieldName mutationThatWasCalled
logType ResponseMapping
parentType Mutation
transformedTemplate
# This is a comment in the response template that had only one pound sign in front rather than two and so resulted in an error
```
(removed all fields apart from the relevant ones)
When looking at this log it becomes apparent that this is going to cause an error because the `transformedTemplate` is displaying the line that should be a comment, when it should be some json structure - but because fieldInError is still 0 we aren't able to pick this out with a direct search, e.g. trying to find all errors within a given time period.
Is there any way we could pick up this error in the logs (we were able to find it when testing was going on, but when things are live there will be many more logs)
Contributor guide
Research direction
Start with the AppSync and CloudWatch logging documentation and the provided ResponseMapping fields, especially fieldInError, logType, and transformedTemplate. Determine whether MappingTemplate errors emit a distinct searchable log signal; done means documenting a reliable query or confirming that no such signal is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, cloud, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100