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

Exceptions are sometimes replaced with "TypeError: exceptions must derive from BaseException" #4096

Closed
sbronson opened this issue May 22, 2021 · 4 comments · Fixed by #4169
Closed
Milestone

Comments

@sbronson
Copy link

# a.py
def create_app(): raise RuntimeError()
$ FLASK_APP=a.py flask run --lazy-loading
$ curl http://127.0.0.1:5000
[...]
Traceback (most recent call last):
  File "[...]/lib/python3.9/site-packages/flask/cli.py", line 356, in __call__
    self._flush_bg_loading_exception()
  File "[...]/lib/python3.9/site-packages/flask/cli.py", line 344, in _flush_bg_loading_exception
    raise exc_info
TypeError: exceptions must derive from BaseException

I expected something about a RuntimeError. raise exc_info[1] here worked for me

raise exc_info

Environment:

  • Python version: 3.9.5
  • Flask version: 2.0.1
@richardcrichardc

This comment has been minimized.

@cygniv404
Copy link

for me it was because i had the same function names for the same endpoint

@collinsmarra

This comment has been minimized.

@thnee
Copy link

thnee commented Jun 18, 2021

Yes thank you for reporting this, glad I am not the only one, thought I was going crazy!

This happens for any exception from anywhere in the project, but only sometimes, seemingly at random. It gets replaced with this TypeError instead of the expected exception.

I have only observed this while running with the flask run dev server, not in production.

It seems to happen right after server autoreload on code update. It seems to happen on the first load of the page after server reload. When reloading the page again, the problem always goes away, and the expected exception is raised.

@davidism davidism linked a pull request Aug 6, 2021 that will close this issue
6 tasks
@davidism davidism added this to the 2.0.2 milestone Aug 6, 2021
@davidism davidism closed this as completed Aug 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants