From 4340949f5734f60eac280b0ef524e53039b5d7a3 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 8 Aug 2025 12:33:14 +0800 Subject: [PATCH 1/2] fix: make startup and shutdown event handlers async in common provider - Fix TypeError: object NoneType can't be used in 'await' expression - FastAPI requires event handlers to be async functions - This was blocking the entire application startup sequence - Fixes the issue where message queue consumers were not starting properly --- apps/devops/app/providers/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/devops/app/providers/common.py b/apps/devops/app/providers/common.py index 64a9a44..656bcc3 100644 --- a/apps/devops/app/providers/common.py +++ b/apps/devops/app/providers/common.py @@ -11,13 +11,13 @@ def register(app): # This hook ensures that a connection is opened to handle any queries # generated by the request. @app.on_event("startup") - def startup(): + async def startup(): pass # This hook ensures that the connection is closed when we've finished # processing the request. @app.on_event("shutdown") - def shutdown(): + async def shutdown(): pass From 04acd78d78359d791d6a7187a2eab4bf03cbea23 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 8 Aug 2025 12:45:21 +0800 Subject: [PATCH 2/2] fix: connect to existing named queue instead of creating anonymous queue - Change AsyncMQClient to connect to existing persistent queue by name - Fix issue where DevOps Service created temporary anonymous queues instead of consuming from the correct named queue - This allows consuming the 42 backlogged messages in freeleaps.devops.reconciler.output queue - Change queue properties: exclusive=False, auto_delete=False, durable=True - Resolves the core issue where messages were split between persistent and temporary queues --- apps/devops/app/backend/infra/rabbitmq/async_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/devops/app/backend/infra/rabbitmq/async_client.py b/apps/devops/app/backend/infra/rabbitmq/async_client.py index a48fc58..39e9f28 100644 --- a/apps/devops/app/backend/infra/rabbitmq/async_client.py +++ b/apps/devops/app/backend/infra/rabbitmq/async_client.py @@ -37,8 +37,10 @@ class AsyncMQClient: name=self.exchange_name, type="direct", auto_delete=False ) + # Connect to existing named queue instead of creating anonymous queue + # channel_name already contains the full queue name from environment variable self.queue = await self.channel.declare_queue( - name=None, exclusive=True, auto_delete=True, durable=False + name=self.channel_name, exclusive=False, auto_delete=False, durable=True ) await self.queue.bind( exchange=self.exchange, routing_key=self.routing_key