Skip to content

Commit

Permalink
🐞 fix: if message's type not str
Browse files Browse the repository at this point in the history
  • Loading branch information
mic1on committed Nov 1, 2023
1 parent bcf9dac commit 7af9003
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/onestep/broker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,13 @@ def __str__(self):
class BaseLocalConsumer(BaseConsumer):

def _to_message(self, data: Any):
try:
message = json.loads(data)
except json.JSONDecodeError:
message = {"body": data}
if isinstance(data, (str, bytes, bytearray)):
try:
message = json.loads(data)
except json.JSONDecodeError:
message = {"body": data}
else:
message = data
if not isinstance(message, dict):
message = {"body": message}
if "body" not in message:
Expand Down

0 comments on commit 7af9003

Please sign in to comment.