[Bug] Azure functions with Python 3.12 FastAPI 500 Exception for `response.delete_cookie()`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start with bindings/datumdef.py, especially parse_to_rpc_http_cookie_list, and bindings/nullable_converters.py at to_nullable_timestamp. Reproduce the failure using function_app.py with func start and the provided curl request; done means response.delete_cookie(key='test') no longer causes a worker exception or HTTP 500.
Written by the indexing model from the issue text.
Description
Expected Behavior
Cookie should have been deleted in the response to the client using code response.delete_cookie() but instead Azure Function worker throws an exception. This is an Azure Function HTTP request Python 3.12 worker with FastAPI.
Actual Behavior
Azure functions Python worker throws a 500 Exception both when testing locally and in Azure, e.g. running locally throws error below
[2025-10-12T20:23:24.965Z] An exception in WorkerInvocationRequest has occurred: ("A 'datetime' or 'int' type was expected instead of a '%s' type. Cannot parse value %s of '%s'.", <class 'datetime.datetime'>, datetime.datetime(2025, 10, 12, 20, 23, 24), 'cookie.expires')
[2025-10-12T20:23:24.967Z] Executed 'Functions.http_app_func' (Failed, Id=8c29b839-a137-47a1-bb15-84a04f094f11, Duration=10ms)
[2025-10-12T20:23:24.968Z] System.Private.CoreLib: Exception while executing function: Functions.http_app_func. System.Private.CoreLib: Result: Failure
Exception: TypeError: ("A 'datetime' or 'int' type was expected instead of a '%s' type. Cannot parse value %s of '%s'.", <class 'datetime.datetime'>, datetime.datetime(2025, 10, 12, 20, 23, 24), 'cookie.expires')
Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.13\WINDOWS\X64\azure_functions_worker_v2\handle_event.py", line 267, in invocation_request
return_value = to_outgoing_proto(
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.13\WINDOWS\X64\azure_functions_worker_v2\bindings\meta.py", line 223, in to_outgoing_proto
return datum_as_proto(datum, protos) # type: ignore
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.13\WINDOWS\X64\azure_functions_worker_v2\bindings\datumdef.py", line 131, in datum_as_proto
cookies=parse_to_rpc_http_cookie_list(datum.value.get('cookies'), protos),
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.13\WINDOWS\X64\azure_functions_worker_v2\bindings\datumdef.py", line 175, in parse_to_rpc_http_cookie_list
expires=to_nullable_timestamp(
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.13\WINDOWS\X64\azure_functions_worker_v2\bindings\nullable_converters.py", line 110, in to_nullable_timestamp
raise TypeError(
.
Steps to Reproduce
- Use the code sample below and save as
function_app.py - Run
func start - Send a HTTP request, e.g.
curl -v http://localhost:7071 - Azure Functions Python worker throws exception in console and returns
HTTP/1.1 500 Internal Server Error
Relevant code being tried
import azure.functions as func
from fastapi import FastAPI
from fastapi.responses import JSONResponse
app = FastAPI()
func_app = func.AsgiFunctionApp(app=app, http_auth_level=func.AuthLevel.ANONYMOUS)
@app.get("/")
def http_trigger():
response = JSONResponse({'message': 'hello world'}, status_code=200)
response.delete_cookie(key='test')
return response
Relevant log output
See log output above
requirements.txt file
azure-functions
fastapi
Where are you facing this problem?
Local - Core Tools and deployed in Azure Function HTTP Python 3.12 app
Function app name
No response
Additional Information
I'm reporting this as I would have expected response.delete_cookie(key='test') to work, and I don't see any previous reported issues for this. As a workaround, it appears response.set_cookie(key='test', max_age=0) can be used, but not ideal.
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 · 2 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
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100