Chalice: Uncaught exception handling improvement

Created on 23 Oct 2018  Â·  6Comments  Â·  Source: aws/chalice

Currently uncaught exceptions log a DEBUG level message (includes stack trace) and return this in the body of the HTTP error response if DEBUG is enabled. An InternalServerError is returned without any logging if DEBUG is not enabled.

Please consider the following alternate behavior:

  • Always log as ERROR level regardless of the DEBUG level of the app. This makes it much easier to monitor and alert based on these error messages.
  • Return the error plus stack trace via the HTTP response if DEBUG is enabled (existing behavior).
  • Return InternalServerError without stack trace if DEBUG is not enabled (existing behavior).

See this section of code:

https://github.com/aws/chalice/blob/947eb8f22ac74c79755dda0491cab6b74a5fc099/chalice/app.py#L738

enhancement

All 6 comments

Thanks for the feedback. Just to clarify, given the last two points are existing behavior, the remaining task is to change the log level to ERROR on any uncaught exceptions? I think that seems reasonable to change.

Yes, just wanted to be very clear how all the other behaviors are great and I wouldn't want to lose them.

Oops, I guess my reply was actually wrong. I am also suggesting that the ERROR level log message is also generated when DEBUG is not enabled. I went to make the code change and realized my mistake. I'll submit a PR in a second so you can see what I'm thinking. Hopefully this change is also acceptable.

Here's the code diff to be clear, and hopefully to encourage progress on this issue ;-)

Hi @dmulter - just changed this into a PR for the chalice project. This is a pretty big deal for me for operational monitoring too.

Merged with #1144

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Erstwild picture Erstwild  Â·  4Comments

laolsson picture laolsson  Â·  4Comments

cdalar picture cdalar  Â·  4Comments

Miserlou picture Miserlou  Â·  4Comments

jarretraim picture jarretraim  Â·  3Comments