Skip to content

Fix Starlette 1.0.0 compatibility in TemplateResponse calls (#64116)#64300

Open
syhstanley wants to merge 1 commit intoapache:mainfrom
syhstanley:fix/starlette-1-0-compatibility
Open

Fix Starlette 1.0.0 compatibility in TemplateResponse calls (#64116)#64300
syhstanley wants to merge 1 commit intoapache:mainfrom
syhstanley:fix/starlette-1-0-compatibility

Conversation

@syhstanley
Copy link
Copy Markdown

@syhstanley syhstanley commented Mar 27, 2026

Starlette 1.0.0 removed the deprecated `TemplateResponse(name, context)`
signature where `request` was passed inside the context dict. This caused
the API server to crash with `TypeError: unhashable type: 'dict'` (HTTP 500)
whenever the SPA catch-all route or the simple auth manager UI was served.

Root cause: Both `core_api/app.py` and `simple_auth_manager.py` were
using the old signature:

# Old (broken on starlette 1.0.0)
templates.TemplateResponse(
    "/index.html",
    {"request": request, "backend_server_base_url": ...},
)

Fix: Update to the current signature (supported since starlette 0.27.0,
so fully backward-compatible with our `>=0.45.0` minimum):

# New (works on starlette 0.45.0 – 1.0.0+)
templates.TemplateResponse(
    request,
    "/index.html",
    {"backend_server_base_url": ...},
)

Also removes the temporary `starlette<1` upper bound added in #64115 and
its associated comment.

Tested locally with starlette 1.0.0:

  • airflow-core/tests/unit/api_fastapi/execution_api/test_app.py — 7/7 passed (includes the previously failing test_access_api_contract)
  • airflow-core/tests/unit/api_fastapi/auth/managers/simple/ — 202/202 passed
  • airflow-core/tests/unit/api_fastapi/core_api/test_security.py + auth routes — 89/89 passed

closes: #64116


Was generative AI tooling used to co-author this PR?
  • Yes (Claude Code)

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg bot commented Mar 27, 2026

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@boring-cyborg boring-cyborg bot added the area:API Airflow's REST/HTTP API label Mar 27, 2026
@syhstanley syhstanley force-pushed the fix/starlette-1-0-compatibility branch from 1a1547e to e93b19b Compare March 27, 2026 14:46
…4116)

Starlette 1.0.0 removed the deprecated TemplateResponse(name, context)
signature where request was passed inside the context dict. Update both
call sites to use the new signature TemplateResponse(request, name, context)
and remove the temporary starlette<1 upper bound added in apache#64115.

closes: apache#64116
@syhstanley syhstanley force-pushed the fix/starlette-1-0-compatibility branch from e93b19b to c4f7892 Compare March 27, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Starlette upper bound on 1.0.0

2 participants