[Bug] Python Azure Function worker incorrectly URL encodes cookie value
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Begin with the ASGI adapter path created by func.AsgiFunctionApp and compare its response-header handling with FastAPI's PlainTextResponse.set_cookie output. Reproduce with func start and curl -v using the value hello//world; done means the Set-Cookie header preserves the expected cookie value and a regression check covers it.
Written by the indexing model from the issue text.
Description
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
- Run
func startor deploy to Azure using sample code provided below - Send a test HTTP request e.g.
curl -v http://localhost:7071/ - Azure Functions worker incorrectly URL encodes the response cookie value in the
Set-Cookieheader
Relevant code being tried
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
N/A
requirements.txt file
azure-functions
fastapi
Where are you facing this problem?
Production Environment (explain below)
Function app name
Private
Additional Information
No response
- Dominant language
- Python
- Stars
- 357
- Forks
- 116
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/azure-functions-python-worker
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug python
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Azure/azure-functions-python-worker#1881 · 2 comments · 3 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
Azure/azure-functions-python-worker#1908 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Azure/azure-functions-python-worker#1906 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in Azure/azure-functions-python-worker
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·