You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "tirkarthi (via GitHub)" <gi...@apache.org> on 2026/01/06 14:50:47 UTC
[I] Change in Airflow API headers due to ordering of middleware [airflow]
tirkarthi opened a new issue, #60165:
URL: https://github.com/apache/airflow/issues/60165
### Apache Airflow version
3.1.5
### If "Other Airflow 3 version" selected, which one?
_No response_
### What happened?
We have a service that takes requests of certain url paths of Airflow API and then uses http client to hit Airflow API service and returns the response with headers back to the load balancer nginx. After upgrade from Airflow 3.1.2 to 3.1.5 we noticed the service is able to hit the Airflow API but there is a change in the header and the response type where in Airflow 3.1.2 it was not chunked and in Airflow 3.1.5 it was chunked. The chunked header is returned back to nginx which also tries to add it's own header which results in error 'upstream sent duplicate header line: "Transfer-Encoding: chunked"' . This results in nginx sending 504 response.
Upon debugging it seems that JWTRefreshMiddleware was added in #55506 with that the middleware order becomes JWTRefreshMiddleware -> GZipMiddleware. The requests go through middleware from top to bottom and the responses go through bottom to top. Looks like JWTRefreshMiddleware is added before GZipMiddleware resulting in chunked vs non-chunked response behavior change.` Upon adjusting the order in `airflow-core/src/airflow/api_fastapi/core_api/app.py` we were able to restore the previous behavior. As per my understanding `GZipMiddleware` should process response to compress it after `JWTRefreshMiddleware` in terms of the response cycle. There was no change in frontend and other parts but we thought to file an issue anyway.
```python
app.add_middleware(GZipMiddleware, minimum_size=100, compresslevel=5)
app.add_middleware(JWTRefreshMiddleware)
```
```python
import httpx
dict(httpx.get("http://localhost:8000/api/v2/monitor/health").headers)
{'date': 'Tue, 06 Jan 2026 13:46:29 GMT', 'server': 'uvicorn', 'content-length': '170',
'content-type': 'application/json', 'content-encoding': 'gzip', 'vary': 'Accept-Encoding'}
```
Change order to have GZipMiddleware at last.
```python
app.add_middleware(JWTRefreshMiddleware)
app.add_middleware(GZipMiddleware, minimum_size=100, compresslevel=5)
```
```python
import httpx
dict(httpx.get("http://localhost:8000/api/v2/monitor/health").headers)
{'date': 'Tue, 06 Jan 2026 14:31:51 GMT', 'server': 'uvicorn', 'content-type': 'application/json',
'content-encoding': 'gzip', 'vary': 'Accept-Encoding', 'transfer-encoding': 'chunked'}
```
### What you think should happen instead?
_No response_
### How to reproduce
Change order and compress size as above in `airflow-core/src/airflow/api_fastapi/core_api/app.py` and use httpx to analyse the change in headers.
### Operating System
Ubuntu 20.04
### Versions of Apache Airflow Providers
_No response_
### Deployment
Virtualenv installation
### Deployment details
_No response_
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Change in Airflow API headers due to ordering of middleware [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 closed issue #60165: Change in Airflow API headers due to ordering of middleware
URL: https://github.com/apache/airflow/issues/60165
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Change in Airflow API headers due to ordering of middleware [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #60165:
URL: https://github.com/apache/airflow/issues/60165#issuecomment-3714999895
cc: @pierrejeambrun @vincbeck
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Change in Airflow API headers due to ordering of middleware [airflow]
Posted by "abhijeets25012-tech (via GitHub)" <gi...@apache.org>.
abhijeets25012-tech commented on issue #60165:
URL: https://github.com/apache/airflow/issues/60165#issuecomment-3715220202
i would like to contribute in it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Change in Airflow API headers due to ordering of middleware [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #60165:
URL: https://github.com/apache/airflow/issues/60165#issuecomment-3777109094
@abhijeets25012-tech Any update on this ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Change in Airflow API headers due to ordering of middleware [airflow]
Posted by "abhijeets25012-tech (via GitHub)" <gi...@apache.org>.
abhijeets25012-tech commented on issue #60165:
URL: https://github.com/apache/airflow/issues/60165#issuecomment-3796517530
yes,i will raise pr soon.Sorry for late update
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Change in Airflow API headers due to ordering of middleware [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on issue #60165:
URL: https://github.com/apache/airflow/issues/60165#issuecomment-3715226667
Assigned
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Change in Airflow API headers due to ordering of middleware [airflow]
Posted by "aru-trackunit (via GitHub)" <gi...@apache.org>.
aru-trackunit commented on issue #60165:
URL: https://github.com/apache/airflow/issues/60165#issuecomment-3718678117
I do confirm that after upgrading from `airflow 3.1.3` to `airflow 3.1.5` kubernetes pod `airflow-api-server` started to restart itself giving error:
1. `Warning Unhealthy 22s (x10 over 7m1s) kubelet Readiness probe failed: Get "http://IP:8080/api/v2/version": context deadline exceeded (Client.Timeout exceeded while awaiting headers)`
2. `Warning Unhealthy 2s (x11 over 7m2s) kubelet Liveness probe failed: Get "http://IP:8080/api/v2/version": context deadline exceeded (Client.Timeout exceeded while awaiting headers)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org