Skip to content

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

Draft
VarunShukla07 wants to merge 2 commits intoapache:mainfrom
VarunShukla07:fix/starlette-1-0-compatibility
Draft

Fix Starlette 1.0.0 compatibility in TemplateResponse calls (#64116)#64121
VarunShukla07 wants to merge 2 commits intoapache:mainfrom
VarunShukla07:fix/starlette-1-0-compatibility

Conversation

@VarunShukla07
Copy link

Updated TemplateResponse calls to use Starlette 1.0.0 new signature.

Starlette 1.0.0 was released on March 22, 2026 and removed the deprecated
TemplateResponse(name, context) signature. The request object must now be
passed as the first argument instead of inside the context dict.

This was causing the API server to crash with:
TypeError: unhashable type: 'dict'

Changes:

  • Updated TemplateResponse calls in core_api/app.py and simple_auth_manager.py to use the new signature: TemplateResponse(request, name, context)
  • Removed the starlette<1 upper bound added in Upper bound limit starlette < 1.0.0 #64115
  • -Updated minimum starlette version to >=1.0.0

fixes: #64116

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg
Copy link

boring-cyborg bot commented Mar 23, 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 23, 2026
@eladkal eladkal added this to the Airflow 3.2.0 milestone Mar 23, 2026
@eladkal eladkal added the type:misc/internal Changelog: Misc changes that should appear in change log label Mar 23, 2026
@eladkal
Copy link
Contributor

eladkal commented Mar 24, 2026

tests are failing
FAILED airflow-core/tests/unit/api_fastapi/execution_api/test_app.py::test_access_api_contract - TypeError: unhashable type: 'dict'

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI isn't happy.

Comment on lines 99 to 100
# Starlette 1.0.0 breaks the API server. Needs more investigation
# https://github.com/apache/airflow/issues/64116
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to remove the comment too.

# Starlette 1.0.0 breaks the API server. Needs more investigation
# https://github.com/apache/airflow/issues/64116
"starlette>=0.45.0,<1",
"starlette>=1.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make it compatible with >=0.45.0 and not force an upgrade to >= 1.0.0 ?

@abhijeets25012-tech
Copy link
Contributor

It looks like the current change assumes only the Starlette 1.0 signature,
but Airflow still supports older versions (>=0.45.0).

This might be causing the CI failures, especially the "unhashable type: 'dict'"
error if the arguments are interpreted incorrectly in older versions.

Would it make sense to make this backward compatible instead?

For example, we could conditionally handle both signatures:

  • For older versions:
    TemplateResponse(name, context, request=request)

  • For >=1.0:
    TemplateResponse(request, name, context)

This would allow supporting both versions without forcing an upgrade.

Also, it might be worth checking if any remaining TemplateResponse calls
still pass request inside the context dict, which could also trigger this error.

@abhijeets25012-tech
Copy link
Contributor

I think there are a couple of issues causing the CI failures here:

  1. Backward compatibility:
    The change assumes only the Starlette >=1.0 signature
    TemplateResponse(request, name, context), but Airflow still supports

=0.45.0. This will break older versions.

We probably need conditional handling based on Starlette version
instead of forcing a single signature.

  1. Context handling:
    The original code included "request" inside the context dict.
    Removing it might break template rendering depending on how templates
    use the request object.

  2. Dependency constraint:
    Having both:
    "starlette>=0.45.0,<1"
    "starlette>=1.0.0"
    is conflicting and likely incorrect.

Maybe we should:

  • First make TemplateResponse usage compatible with both versions
  • Then relax the upper bound cleanly

This should also fix the "unhashable type: 'dict'" error seen in CI.

@saivarmaakireddy270-star

Hi! I’m a new contributor and was exploring this issue.

I see this PR updates TemplateResponse usage for Starlette 1.0.0. I’d love to help—are there any remaining issues, failing tests, or edge cases I can work on?

Thanks!

@pierrejeambrun pierrejeambrun marked this pull request as draft March 26, 2026 16:27
@pierrejeambrun
Copy link
Member

Converted to draft. PR isn't ready for another round of review. (un-addressed comments + CI failing)

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 type:misc/internal Changelog: Misc changes that should appear in change log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Starlette upper bound on 1.0.0

5 participants