Azure / Azure/azure-functions-python-worker
[Bug] Python Azure Function worker incorrectly URL encodes cookie value
- 主要言語
- Python
- スター
- 357
- フォーク
- 116
- 平均マージ
- 32分
- マージ済み PR(30日)
- 1
説明
### Expected Behavior
Azure Function worker using Python FastAPI should not URL encode cookie values
Expected behavior on HTTP Response Headers:
`set-cookie: test="hello//world"; Path=/; SameSite=lax`
e.g. when using Python FastAPI without Azure Functions, it correctly does not URL encode.
````
import uvicorn
from fastapi import FastAPI
from fastapi.responses import PlainTextResponse
app = FastAPI()
@app.get("/")
def http_trigger():
response = PlainTextResponse("", status_code=200)
response.set_cookie(key='test', value='hello//world')
return response
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=7071)
````
Run `curl -v http://localhost:7071/` and response is correct as `set-cookie: test="hello//world"; Path=/; SameSite=lax`
### Actual Behavior
Actual incorrect behavior on HTTP Response Headers, cookie value is incorrect and unexpectedly URL encoded
`Set-Cookie: test=hello%2F%2Fworld; domain=; path=/; samesite=lax`
Tested bug with
* Python 3.12 with FastAPI
* Azure Functions Core tools 4.3.0 locally
* Deployed to production Azure Function
### Steps to Reproduce
1. Run `func start` or deploy to Azure using sample code provided below
2. Send a test HTTP request e.g. `curl -v http://localhost:7071/`
3. Azure Functions worker incorrectly URL encodes the response cookie value in the `Set-Cookie` header
### Relevant code being tried
```shell
import azure.functions as func
from fastapi import FastAPI
from fastapi.responses import PlainTextResponse
app = FastAPI()
func_app = func.AsgiFunctionApp(app=app, http_auth_level=func.AuthLevel.ANONYMOUS)
@app.get("/")
def http_trigger():
response = PlainTextResponse("", status_code=200)
response.set_cookie(key='test', value='hello//world')
return response
```
### Relevant log output
```shell
N/A
```
### requirements.txt file
```shell
azure-functions
fastapi
```
### Where are you facing this problem?
Production Environment (explain below)
### Function app name
Private
### Additional Information
_No response_
コントリビューションガイド
調査の方向性
func.AsgiFunctionApp によって作成された ASGI アダプターのパスから始め、そのレスポンスヘッダー処理を FastAPI の PlainTextResponse.set_cookie の出力と比較します。値 hello//world を使って func start と curl -v で再現します。Set-Cookie ヘッダーが期待される Cookie 値を保持し、回帰チェックでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- azure, fastapi, python
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100