Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(platform): Capture Sentry Block Errors Correctly (#11404)

Swifty9438817702ad
diff --git a/autogpt_platform/backend/backend/executor/manager.py b/autogpt_platform/backend/backend/executor/manager.py
index d4c362e6aa..f04102a950 100644
--- a/autogpt_platform/backend/backend/executor/manager.py
+++ b/autogpt_platform/backend/backend/executor/manager.py
@@ -252,9 +252,9 @@ async def execute_node(
output_size += len(json.dumps(output_data))
log_metadata.debug("Node produced output", **{output_name: output_data})
yield output_name, output_data
- except Exception:
+ except Exception as ex:
# Capture exception WITH context still set before restoring scope
- sentry_sdk.capture_exception(scope=scope)
+ sentry_sdk.capture_exception(error=ex, scope=scope)
sentry_sdk.flush() # Ensure it's sent before we restore scope
# Re-raise to maintain normal error flow
raise
diff --git a/autogpt_platform/backend/backend/util/exceptions.py b/autogpt_platform/backend/backend/util/exceptions.py
index d2cb171126..1fff9df9c0 100644
--- a/autogpt_platform/backend/backend/util/exceptions.py
+++ b/autogpt_platform/backend/backend/util/exceptions.py
@@ -5,13 +5,9 @@ class BlockError(Exception):
"""An error occurred during the running of a block"""
def __init__(self, message: str, block_name: str, block_id: str) -> None:
- super().__init__(message)
- self.message = message
- self.block_name = block_name
- self.block_id = block_id
-
- def __str__(self):
- return f"raised by {self.block_name} with message: {self.message}. block_id: {self.block_id}"
+ super().__init__(
+ f"raised by {block_name} with message: {message}. block_id: {block_id}"
+ )
class BlockInputError(BlockError, ValueError):