Skip to content

fix: report actionable failures to Sentry - #1125

Merged
ramantehlan merged 16 commits into
mainfrom
sd/sentry-coverage-increase
Oct 25, 2026
Merged

ramantehlan merged 16 commits into
mainfrom
sd/sentry-coverage-increase

Conversation

@ramantehlan

@ramantehlan ramantehlan commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Report a server or core log to Sentry only when the catch site marks it with reportable_error.
  • Mark infrastructure and unexpected internal failures, including network and timeout errors on mixed authorization and LLM logs. Provider inference errors, bad credentials, rate limits, and client disconnects stay in the logs.
  • Stop reporting missing sandbox versions, rejected sandbox credentials, and the duplicate lower-level build failure.

Test plan

  • pnpm --filter @truefoundry/trueforge exec jest --config jest.unit.config.cjs tests/unit/sentry/reportMarkedLog.test.ts tests/unit/apis/auth.test.ts tests/unit/sandbox/progressSandboxEnvironmentVersion.test.ts tests/unit/controller/sandboxEnvBuild.test.ts
  • pnpm --filter @truefoundry/trueforge-core exec jest --config jest.config.cjs tests/core/llm/VercelAILLM.stream.test.ts
  • Confirm a marked log reaches Sentry and an unmarked provider error does not
  • Confirm the printed log does not include reportable_error

Note

Medium Risk
Broad changes to error observability and many failure paths; mis-tagged reportable_error or isReportableError edge cases could over- or under-alert Sentry without affecting request handling.

Overview
Introduces opt-in Sentry reporting via Winston: error logs can carry a reportable_error metadata field; when Sentry is enabled, a log formatter turns the log message into the event title, uses the wrapped error for cause/stack, attaches optional extra/filepath, and strips reportable_error from console/JSON output.

Adds isReportableError in core so HTTP 200–499 (including statusCode/status on the error cause chain) is treated as non-reportable—used to avoid Sentry noise for provider 4xx, OAuth failures, and similar client errors while still logging them.

Replaces ad-hoc captureCriticalException calls across server, controller, Daytona sandbox, and TrueFoundry dual-write paths with marked logs; removes Daytona's onCriticalAlert hook. Sentry scope now auto-tags tenant/request/session/turn from log context and enables linked errors integration.

Call sites across agent turns, LLM streaming, sandboxes, Redis, request-reply, and API handlers are updated to mark infrastructure/unexpected failures; several paths stop reporting expected cases (missing sandbox versions, authz build failures, duplicate build errors, provider/model client errors). Turn draining adds reporting for unexpected turn.done error/abandoned-timeout cancellations.

Reviewed by Cursor Bugbot for commit 3b88b6c. Bugbot is set up for automated code reviews on this repo. Configure here.

Mark infrastructure and unexpected internal errors on the log record so the server logger can send them to Sentry without reporting provider inference errors, bad credentials, or client disconnects.

Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b88b6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@truefoundry/trueforge Patch
@truefoundry/trueforge-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge-core/src/request-reply/executor.ts
Comment thread packages/trueforge/src/app.ts Outdated
A normal Redis close during shutdown is not a failure, and an HTTP 500 whose cause was already marked should not be reported again.

Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Restore the sandbox captures this branch had dropped, and remember a directly captured error so the HTTP handler does not send it again.

Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Comment thread packages/trueforge/tests/unit/apis/auth.test.ts Outdated
Comment thread packages/trueforge-core/src/core/util/reportableErrorLog.ts Outdated
Comment thread packages/trueforge/src/sentry/reportMarkedLog.ts Outdated
Comment thread packages/trueforge/src/logger.ts Outdated
Comment thread packages/trueforge/src/sentry/reportMarkedLog.ts Outdated
Comment thread packages/trueforge-core/src/core/sandbox/codeMode/nats/CodeModeNatsTransport.ts Outdated
Comment thread packages/trueforge/src/sentry/captureCriticalException.ts Outdated
Comment thread packages/trueforge-core/src/core/util/errorLogFields.ts
Comment thread packages/trueforge-core/src/core/util/reportableErrorLog.ts
Comment thread packages/trueforge-core/src/request-reply/executor.ts Outdated
Comment thread packages/trueforge-core/src/request-reply/executor.ts Outdated
Comment thread packages/trueforge-core/src/request-reply/executor.ts Outdated
Comment thread packages/trueforge-core/src/request-reply/executor.ts
Comment thread packages/trueforge/src/controller.ts Outdated
Comment thread packages/trueforge/src/main.ts Outdated
Comment thread packages/trueforge/src/main.ts Outdated
Comment thread packages/trueforge/src/app.ts Outdated
Comment thread packages/trueforge/src/controller/Controller.ts
Comment thread packages/trueforge/src/apis/turns.ts
Comment thread packages/trueforge-core/src/core/llm/VercelAILLM.ts Outdated
Comment thread packages/trueforge/src/sentry/reportMarkedLog.ts
Comment thread packages/trueforge-core/src/core/sandbox/codeMode/CodeModeDispatcher.ts Outdated
Comment thread .changeset/sentry-allowlisted-logs.md

@chiragjn chiragjn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it approved with some comments

…crease

Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>

# Conflicts:
#	packages/trueforge-core/src/core/llm/VercelAILLM.ts

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge-core/src/core/llm/VercelAILLM.ts

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/sentry/initSentry.ts

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge-core/src/core/util/reportableErrorLog.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/truefoundry/TrueFoundryAgentStore.ts
Comment thread packages/trueforge/src/apis/turns.ts
Comment thread packages/trueforge/src/sandbox/progressSandboxEnvironmentVersion.ts Outdated
Comment thread packages/trueforge/src/controller/sandboxEnvBuild.ts Outdated
ramantehlan and others added 3 commits October 24, 2026 16:13
The marker stayed on the printed line whenever Sentry did not start, and production tags collapsed to the server bundle or skipped core. Wrapped provider responses from 200 through 499 stay in the logs.

Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Dual-write cleanup keeps the agent identity on the event. A turn.done error only has a message, so provider failures stay classified where they are thrown. Missing sandbox versions, rejected credentials, and API responses the server already logged stay in the logs.

Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/truefoundry/TrueFoundryAgentStore.ts Outdated
ramantehlan and others added 3 commits October 24, 2026 17:49
The agent store log already carries the agent identity. The HTTP 500 handler skips an error that was already marked, so the same cleanup failure is not sent again.

Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c897511. Configure here.

Comment thread packages/trueforge-core/tests/core/util/errorLogFields.test.ts Outdated
@ramantehlan
ramantehlan merged commit 82e50e2 into main Oct 25, 2026
16 checks passed
@ramantehlan
ramantehlan deleted the sd/sentry-coverage-increase branch October 25, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants