How to properly raise python lambda exception to appsync response resolver

1

Hello, I'm trying to implement some custom declared exceptions in a python aws lambda.
The lambda function is correctly hooked up to an appsync cfnresolver. (I get the proper response when testing the query manually in the AWS console)

raising a custom exception in that lamba function for testing also generates and error.

But the issue I'm running in is that if I manually define the response_mapping_template of that cfnresolver the errorType of the resulting response turn into "lambda:unhandled" instead of the "CustomException" I get when I don't define the response_mapping_template.
And while it does work when I don't define the response_mapping_template. That's not really a solution since the response_mapping_template will be needed in the future.

I've looked everywhere. And tried different solutions that allows me to use an own defined response_mapping_template and still get the correct errorType in the response. But nothing I've tried resolves my issue.
And sadly my issue is with VTL. Else I could just look into the code directly to see what my issue is.

Things I've tried:

  • Both 2017 and 2018 request_mapping_template. This changed nothing.
  • Removing the response_mapping_template. This worked. But yeah no response_mapping_template functionality isn't viable.
  • Tried looking for the defaults of response_mapping_template but it was too obscure to find in the sdk sadly. (It would be nice if someone could show me where?)
  • A few different response_mapping_template syntaxes. I've found roughly 3 different ones on stackoverflow and aws pages. Non did anything different.

I'm kinda stumped after looking for two days now.
Are you not supposed to use normal exceptions in Lambda's?
Are you supposed to populate the response object with the error info?
Am I overlooking any documentation?

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions