Skip to content

Commit 8dd08e8

Browse files
committed
fix path type
1 parent 2128645 commit 8dd08e8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

slack_bolt/adapter/sanic/async_handler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def to_async_bolt_request(req: Request, addition_context_properties: Optional[Di
2424

2525

2626
def to_sanic_response(bolt_resp: BoltResponse) -> HTTPResponse:
27-
27+
"""
28+
Converts a BoltResponse to a Sanic HTTPResponse, ensuring compatibility with Sanic's add_cookie method.
29+
"""
2830
# Create the HTTPResponse with BoltResponse attributes
2931
resp = HTTPResponse(
3032
status=bolt_resp.status,
@@ -42,13 +44,17 @@ def to_sanic_response(bolt_resp: BoltResponse) -> HTTPResponse:
4244
# Convert "max-age" if provided
4345
max_age = int(c["max-age"]) if c.get("max-age") else None
4446

47+
# Ensure values are of the correct type before passing to add_cookie
48+
path = str(c.get("path")) if c.get("path") else "/"
49+
domain = str(c.get("domain")) if c.get("domain") else None
50+
4551
# Add cookie with Sanic's add_cookie method
4652
resp.add_cookie(
4753
key=key,
4854
value=c.value,
4955
expires=expires,
50-
path=c.get("path"),
51-
domain=c.get("domain"),
56+
path=path,
57+
domain=domain,
5258
max_age=max_age,
5359
secure=True,
5460
httponly=True,

0 commit comments

Comments
 (0)