Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

break up giant try except block in handler.py #153

Closed
collingreen opened this issue Jun 23, 2016 · 1 comment
Closed

break up giant try except block in handler.py #153

collingreen opened this issue Jun 23, 2016 · 1 comment

Comments

@collingreen
Copy link
Collaborator

https://github.com/Miserlou/Zappa/blob/master/zappa/handler.py#L77-L183

The try catch in handler.py covers too many things, which ends up obfuscating/swallowing errors in certain situations. Additionally, the general except clause allows further failures -- for example, if an error causes app_module to not get set, the actual exception is consumed (and printed), then another exception is caused when the code tries to look up the debug flag on the app_module variable.

I noticed this when trying to track down an issue that this was hiding. Some details so other people can maybe find this and get insight if they have the same superficial symptoms.

  1. On requests, the browser returns {"message":"Missing Authentication Token"} which is not anywhere in the project code.

  2. Using zappa tail <stage> showed an error printed by the print statement in the except Exception as e block https://github.com/Miserlou/Zappa/blob/master/zappa/handler.py#L173 then a stack trace of a subsequent exception:

    UnboundLocalError: local variable 'app_module' referenced before assignment

FYI - my error was being thrown by my code during import -- look at the line above 'local variable app_module referenced before assignment' if you are having a similar bug and are trying to debug your own application.

@Miserlou
Copy link
Owner

Has this been properly addressed by the Australian error-handling code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants