add onError callback with secret redaction for external error reporting#26
add onError callback with secret redaction for external error reporting#26jackcbrown89 wants to merge 1 commit intomainfrom
Conversation
Replace implicit error swallowing with an explicit onError hook that callers can wire to their own reporting (e.g. Sentry). Errors and metadata are redacted via redactError/redactSecrets before reaching the callback, and the callback is wrapped in try/catch so it can never break the session's own error handling.
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 58f51c1. Configure here.
| this.config.onError?.(error, { | ||
| ...serializeErrorMetadata(error), | ||
| phase: "session", | ||
| }); |
There was a problem hiding this comment.
Server-level onError bypasses secret redaction
Medium Severity
The onError call in server.ts passes the raw error and unredacted serializeErrorMetadata(error) directly to the callback, unlike session.ts's reportError which properly wraps both in redactError and redactSecrets. If session.run() ever rejects with an error containing secrets, those secrets will leak unredacted to the external error reporting callback (e.g. Sentry), defeating the stated purpose of this PR.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 58f51c1. Configure here.


Replace implicit error swallowing with an explicit onError hook that callers can wire to their own reporting (e.g. Sentry). Errors and metadata are redacted via redactError/redactSecrets before reaching the callback, and the callback is wrapped in try/catch so it can never break the session's own error handling.
Note
Medium Risk
Introduces a new
onErrorcallback into the WebSocket server/session error paths and changes how errors are propagated to external handlers; mistakes could leak sensitive data or alter observability behavior. Redaction and try/catch guards reduce blast radius but the hook runs in multiple failure scenarios.Overview
Adds an optional
onError(error, metadata)hook toRuntimeUseServer/WebSocketSessionso callers can report internal failures (e.g., parsing, websocket, artifact upload, agent/command execution, and top-level session errors).Introduces
redactErrorinerror-utils.tsand uses it (plusredactSecrets) to ensure errors/stack traces and serialized metadata are secret-redacted before invokingonError, and wraps callback execution intry/catchso reporting cannot break session error handling.Also bumps the
runtimeusepackage-lock version from0.3.0to0.9.1.Reviewed by Cursor Bugbot for commit 58f51c1. Bugbot is set up for automated code reviews on this repo. Configure here.