Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

HTTP 500 errors after upgrading to Flask 2.3.0 #222

Description

@asjohnston-asf

Download requests fail with HTTP 500 responses after upgrading to Flask >= 2.3.0. The traceback is:

[ERROR] AttributeError: 'Flask' object has no attribute 'before_first_request'
Traceback (most recent call last):
  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/var/task/door/__init__.py", line 5, in <module>
    from door import routes  # noqa Has to be at end of file or will cause circular import
  File "/var/task/door/routes.py", line 28, in <module>
    @app.before_first_request

app.before_first_request was deprecated in Flask 2.2.0 and removed in Flask 2.3.0.

Our app uses before_first_request at https://github.com/asfadmin/grfn-distribution/blob/test/door/src/door/routes.py#L28 to fetch a private key from secrets manager once when the app is initialized. We'll need to refactor where that initialization is done, or pursue #204 which eliminates the need for the private key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions