aws-appsync-community icon indicating copy to clipboard operation
aws-appsync-community copied to clipboard

How to detect mapping template error in logs

Open alecwcp opened this issue 4 years ago • 3 comments

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)

alecwcp avatar Apr 17 '20 14:04 alecwcp

I think I have a similar issue:

I have enabled the logs for AppSync, including all logs for Field resolver log level and verbose.

what I try to create an item the client gets an error - "Variable 'nextMilestoneQuarter' has an invalid value. Unable to parse 2021-01-01T00:00:00.000Z as a valid date." and the item isn't added to the table but there is no log for the error in the appsync/api logs.

I can see the request, response, begin and end tracing but no traces and no error for a successful putItem request I can see all the traces for all the fields

I use Amplify api

alissaVrk avatar Oct 25 '20 08:10 alissaVrk

Same issue... is there no way to detect these?!?

benm5678 avatar Jun 05 '21 17:06 benm5678

same issue, with a mutation and resolver to dynamoDb data source: request mapping works and writes to db while error in response mapping is not logged (as it would with a query)

r0bs avatar Oct 19 '21 16:10 r0bs