Skip to content

[Bug]: Unhandled-exception tests permanently skipped due to Flask 3.x route-locking — no real coverage for catch-all error handler #1250

Description

@sameerapujari

What happened?

In tests/test_error_handling.py (lines 239–272), two tests —
test_unhandled_exception_returns_500 and
test_unhandled_exception_does_not_leak_message — attempt to dynamically
register a new route on the shared global app instance inside the
test, after the app has already served requests in earlier tests.
Flask 3.x explicitly disallows registering routes after the first
request has been handled, so both tests are currently marked:
python@pytest.mark.skip(reason="Flask 3.x route registration restriction")
This means the app's catch-all Exception handler
(unhandled_exception in src/errors/handlers.py) — the code
responsible for making sure raw Python error messages never leak to
users — currently has zero automated test coverage for the actual
Flask routing integration path.

Steps to reproduce

from app import app
client = app.test_client()
client.get('/') # force first request

@app.route('/test-unhandled-exception-xyz')
def _broken_route():
raise RuntimeError('deliberate crash for testing')

Expected behaviour

Both tests should run (not be skipped) and pass, by testing the unhandled-exception
flow against a fresh, isolated Flask app instance instead of the shared global app.
This would restore real test coverage proving that:

  1. An unhandled exception raised inside a route returns a 500 response
    (test_unhandled_exception_returns_500)
  2. The 500 response does not leak the raw exception message to the client
    (test_unhandled_exception_does_not_leak_message)

Currently neither guarantee has any automated test coverage, since both tests
are skipped.

Area of the app affected

Other

Python version

3.11.9

Operating system

Windows 11

Relevant error output or logs

Before submitting

  • I searched existing issues and this has not been reported before.
  • I can reproduce this bug consistently with the steps above.
  • I am running the latest version of the main branch.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions