I really like that python exceptions bubble up to the response, and offer the requester a meaningful response. I also really like that Regex can sniff out the response type we note in the error message. I just really hate that the stack trace is included in there.
S'far as I can tell, there's two good ways of formatting errors.
1) Response Templates
Introduce custom request bodies for each of the status codes. You can get at just the error message with a Response template of the format:
You've got to manually create this through the AWS console for each endpoint, for each of the 8 response codes. To make it worse, running a sls deploy completely erases them. So unfortunately until serverless supports custom response body templates, this doesn't make any sense. They are so close to being done though -> https://github.com/serverless/serverless/pull/2014
2) AWS APIGW WSGI
AWS APIGW now supports custom WSGIs and this guy created a nice little pip installer to facilitate it. Concerns with this however are the inclusion of a venv in the api service. It's obviously not impossible, but it sucks to carry all that weight along for the deploy.
Conclusion
Having the stack trace come through isn't the end of the world, and I'm pretty biased to option 1) so I think we'll put a lid on this until the serverless team merges in pull #2014.
I really like that python exceptions bubble up to the response, and offer the requester a meaningful response. I also really like that Regex can sniff out the response type we note in the error message. I just really hate that the stack trace is included in there.
S'far as I can tell, there's two good ways of formatting errors.
1) Response Templates
Introduce custom request bodies for each of the status codes. You can get at just the error message with a Response template of the format:
You've got to manually create this through the AWS console for each endpoint, for each of the 8 response codes. To make it worse, running a
sls deploy
completely erases them. So unfortunately until serverless supports custom response body templates, this doesn't make any sense. They are so close to being done though -> https://github.com/serverless/serverless/pull/20142) AWS APIGW WSGI
AWS APIGW now supports custom WSGIs and this guy created a nice little pip installer to facilitate it. Concerns with this however are the inclusion of a
venv
in the api service. It's obviously not impossible, but it sucks to carry all that weight along for the deploy.Conclusion
Having the stack trace come through isn't the end of the world, and I'm pretty biased to option 1) so I think we'll put a lid on this until the serverless team merges in pull #2014.