@@ -42,9 +42,20 @@ def __init__(
4242 context: The context in this request.
4343 mode: The mode used for this request. (either "http" or "socket_mode")
4444 """
45- if mode == "http" and not isinstance (body , str ):
46- raise BoltError (error_message_raw_body_required_in_http_mode ())
47- self .raw_body = body if mode == "http" else ""
45+ if mode == "http" :
46+ # HTTP Mode
47+ if not isinstance (body , str ):
48+ raise BoltError (error_message_raw_body_required_in_http_mode ())
49+ self .raw_body = body if body is not None else ""
50+ else :
51+ # Socket Mode
52+ if body is not None and isinstance (body , str ):
53+ self .raw_body = body
54+ else :
55+ # We don't convert the dict value to str
56+ # as doing so does not guarantee to keep the original structure/format.
57+ self .raw_body = ""
58+
4859 self .query = parse_query (query )
4960 self .headers = build_normalized_headers (headers )
5061 self .content_type = extract_content_type (self .headers )
@@ -56,7 +67,7 @@ def __init__(
5667 raise BoltError (error_message_unknown_request_body_type ())
5768
5869 self .context = build_context (BoltContext (context if context else {}), self .body )
59- self .lazy_only = self .headers .get ("x-slack-bolt-lazy-only" , [False ])[0 ]
70+ self .lazy_only = bool ( self .headers .get ("x-slack-bolt-lazy-only" , [False ])[0 ])
6071 self .lazy_function_name = self .headers .get (
6172 "x-slack-bolt-lazy-function-name" , [None ]
6273 )[0 ]
0 commit comments