You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm updating some code to work after the removal of CookieJar.items() and while before it was safe to call it if there was no cookie header set now it's raising a KeyError. Maybe it's worthwhile to handle that and return an empty list instead.
Code snippet
No response
Expected Behavior
No response
How do you run Sanic?
Sanic CLI
Operating System
Linux
Sanic Version
24.12.0
Additional context
No response
The text was updated successfully, but these errors were encountered:
Do you have a snippet of what you are trying to do?
This is APM code reading data out of the response
Before 24.12:
return {k: {"value": v.value, "path": v["path"]} for k, v in cookies.items()}
After:
try:
return {cookie.key: {"value": cookie.value, "path": cookie.path} for cookie in cookies.cookies}
except KeyError:
# cookies.cookies assumes Set-Cookie header will be there
return {}
When testing this if I don't add a call to add_cookie in the response the KeyError is raised. This is an example test handler:
@app.get("/add-cookies")
async def add_cookies(request):
response = json({"data": "message"}, headers={"sessionid": 1234555})
# without the following line I get the KeyError
response.add_cookie("some", "cookie")
return response
Is there an existing issue for this?
Describe the bug
I'm updating some code to work after the removal of CookieJar.items() and while before it was safe to call it if there was no cookie header set now it's raising a KeyError. Maybe it's worthwhile to handle that and return an empty list instead.
Code snippet
No response
Expected Behavior
No response
How do you run Sanic?
Sanic CLI
Operating System
Linux
Sanic Version
24.12.0
Additional context
No response
The text was updated successfully, but these errors were encountered: