From b20a907462af41e4c5768d305a10c098ffb135a4 Mon Sep 17 00:00:00 2001 From: Otto Date: Fri, 6 Feb 2026 16:12:53 +0000 Subject: [PATCH] fix: add exception handling for block instantiation in get_stats Matches existing defensive pattern in get_missing_items() (lines 188-200). Prevents a single broken block from crashing the stats endpoint. Addresses CodeRabbit review comment. --- .../backend/backend/api/features/store/content_handlers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/backend/backend/api/features/store/content_handlers.py b/autogpt_platform/backend/backend/api/features/store/content_handlers.py index eda1babeb7..51da911fa1 100644 --- a/autogpt_platform/backend/backend/api/features/store/content_handlers.py +++ b/autogpt_platform/backend/backend/api/features/store/content_handlers.py @@ -267,7 +267,11 @@ class BlockHandler(ContentHandler): # Filter out disabled blocks and excluded blocks - they're not indexed enabled_block_ids = [] for block_id, block_cls in all_blocks.items(): - block_instance = block_cls() + try: + block_instance = block_cls() + except Exception as e: + logger.warning(f"Failed to instantiate block {block_id}: {e}") + continue if block_instance.disabled: continue if (