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?

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠