aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
507 stars 32 forks source link

How to detect mapping template error in logs #100

Open alecwcp opened 4 years ago

alecwcp commented 4 years ago

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)

alissaVrk commented 4 years ago

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

benm5678 commented 3 years ago

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

r0bs commented 3 years ago

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)