amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

AppSync Mock - Unable to convert document to class ...LambdaVersionedConfig.

Open NeillGiraldo opened this issue 6 years ago • 5 comments

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug On [email protected] this request mapping template works

#**
The value of 'payload' after the template has been evaluated
will be passed as the event to AWS Lambda.
*#
{
  "version" : "2017-02-28",
  "operation": "Invoke",
  "payload": {
    "arguments": $util.toJson($context.args),
    "field": "changeUser",
  }
}

however on the current version is not working.

Amplify CLI Version [email protected]

To Reproduce Example provided in the description

Expected behavior Should Invoke lambda data source

Desktop (please complete the following information):

  • OS: Mac
  • Node Version. v10.15.3

NeillGiraldo avatar Mar 04 '20 12:03 NeillGiraldo

@NeillGiraldo what error message do you see when you try this?

nikhname avatar Mar 05 '20 01:03 nikhname

Hi @nikhname, This is the error that is being thrown.

{
  "data": {
    "changeUser": null
  },
  "errors": [
    {
      "message": "Unable to convert {\n  \"version\" : \"2017-02-28\",\n  \"operation\": \"Invoke\",\n  \"payload\": {\n  \t\"arguments\": {\"username\":\"changedUser\"},\n    \"field\": \"changeUser\",\n  }\n} to class com.amazonaws.deepdish.transform.model.lambda.LambdaVersionedConfig.",
      "errorType": "MappingTemplate",
      "data": null,
      "errorInfo": null,
      "path": [
        "changeUser"
      ],
      "locations": [
        {
          "line": 6,
          "column": 3,
          "sourceName": "GraphQL request"
        }
      ]
    }
  ]
}

NeillGiraldo avatar Mar 05 '20 09:03 NeillGiraldo

Hi @nikhname , I checked a bit deeper and it was because of the trailing comma at the end of the payload. JSON.parse was failing because of it.

This applies to all my previous Mapping Templates.

NeillGiraldo avatar Mar 05 '20 09:03 NeillGiraldo

We do strict evaluation of the JSON which is the recommended practice. Let us know if you're still stuck with this.

kaustavghosh06 avatar Mar 06 '20 00:03 kaustavghosh06

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 26 '21 14:05 github-actions[bot]