Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: non kombu json message decoding in SQS transport #1306

Merged
merged 2 commits into from
Mar 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions kombu/transport/SQS.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,21 @@ def _put(self, queue, message, **kwargs):
else:
c.send_message(**kwargs)

@staticmethod
def __b64_encoded(byte_string):
try:
return base64.b64encode(base64.b64decode(byte_string)) == byte_string
except Exception: # pylint: disable=broad-except
return False

def _message_to_python(self, message, queue_name, queue):
body = message['Body'].encode()
try:
body = base64.b64decode(message['Body'].encode())
if self.__b64_encoded(body):
body = base64.b64decode(body)
except TypeError:
body = message['Body'].encode()
pass

payload = loads(bytes_to_str(body))
if queue_name in self._noack_queues:
queue = self._new_queue(queue_name)
Expand Down