Skip to content

Commit cc40c55

Browse files
Trying to fix structured logging
1 parent 73e7909 commit cc40c55

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

app/consumer/inbound_consumer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def process_inbound_message_task(message: AbstractIncomingMessage):
2121
async with message.process(): # Automatically ACKs if no exception occurs
2222
try:
2323
payload_string: str = message.body.decode()
24-
headers: HeadersType = message.headers
24+
headers = dict(message.headers) if message.headers else {}
2525
count: int = headers.get("count", 1)
2626
message_id: str = headers.get("message_id", str(uuid.uuid4()))
2727
message_context: dict[str, Any] = {
@@ -45,7 +45,10 @@ async def process_inbound_message_task(message: AbstractIncomingMessage):
4545
except Exception as e:
4646
logger.error(f"Unexpected Exception!: {repr(e)}")
4747
headers.update({"count": count + 1, "message_id": message_id})
48-
await publish_to_inbound_retry(samples=samples, headers=headers)
48+
if samples is None:
49+
logger.error(f"Unable to parse raw payload {payload_string}")
50+
else:
51+
await publish_to_inbound_retry(samples=samples, headers=headers)
4952
finally:
5053
structlog.contextvars.clear_contextvars()
5154

0 commit comments

Comments
 (0)