Skip to content

Commit 9438817

Browse files
authored
fix(platform): Capture Sentry Block Errors Correctly (#11404)
Currently we are capturing block errors via the scope only, this change captures the error directly. ### Changes 🏗️ - capture the error as well as the scope in the executor manager - Update the block error message to include additional details - remove the __str__ function from blockerror as it is no longer needed ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Checked that errors are still captured in dev
1 parent 184a73d commit 9438817

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

autogpt_platform/backend/backend/executor/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ async def execute_node(
252252
output_size += len(json.dumps(output_data))
253253
log_metadata.debug("Node produced output", **{output_name: output_data})
254254
yield output_name, output_data
255-
except Exception:
255+
except Exception as ex:
256256
# Capture exception WITH context still set before restoring scope
257-
sentry_sdk.capture_exception(scope=scope)
257+
sentry_sdk.capture_exception(error=ex, scope=scope)
258258
sentry_sdk.flush() # Ensure it's sent before we restore scope
259259
# Re-raise to maintain normal error flow
260260
raise

autogpt_platform/backend/backend/util/exceptions.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ class BlockError(Exception):
55
"""An error occurred during the running of a block"""
66

77
def __init__(self, message: str, block_name: str, block_id: str) -> None:
8-
super().__init__(message)
9-
self.message = message
10-
self.block_name = block_name
11-
self.block_id = block_id
12-
13-
def __str__(self):
14-
return f"raised by {self.block_name} with message: {self.message}. block_id: {self.block_id}"
8+
super().__init__(
9+
f"raised by {block_name} with message: {message}. block_id: {block_id}"
10+
)
1511

1612

1713
class BlockInputError(BlockError, ValueError):

0 commit comments

Comments
 (0)