Skip to content

minor refactor sandbox - #1008

Open
thesujai wants to merge 3 commits into
mainfrom
fix/daytona-on-error-callback-rename
Open

thesujai wants to merge 3 commits into
mainfrom
fix/daytona-on-error-callback-rename

Conversation

@thesujai

@thesujai thesujai commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #

Changes

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Low Risk
Alerting behavior is refactored but P1 Sentry reporting for non-auth create failures is preserved; auth errors are still excluded from P1 at the host layer.

Overview
Replaces Daytona provider onCriticalAlert with a host-owned onError hook that runs only when a new sandbox create fails (via getOrCreateSandbox → createNewSandbox). The provider no longer decides which failures are P1-worthy; it logs and invokes the hook, then rethrows a normalized Error.

trueforge wires onError to captureCriticalException with the same P1 tags as before, but skips auth/permission errors in the host (isDaytonaAuthError / isDaytonaPermissionError) instead of inside the provider. Restore/exec/file paths call getOrCreateSandbox without onError, so they do not trigger that alerting path.

Includes a patch changeset for @truefoundry/trueforge-core and @truefoundry/trueforge.

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

@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2bcd649

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-core Patch
@truefoundry/trueforge 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.

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 0f8defa. Configure here.

this.natsBridgePort = options.natsBridgePort ?? DEFAULT_SANDBOX_NATS_WS_PORT;
this.previewUrlExpirySeconds = options.previewUrlExpirySeconds ?? DEFAULT_PREVIEW_URL_EXPIRY_SECONDS;
this.onCriticalAlert = options.onCriticalAlert;
this.onError = options.onError;

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.

There are many places in this file has catch (error) {
Why should they not be piped to onError?

If they should not be piped then onError should be optional arg of getOrCreateSandbox?

});
this.onCriticalAlert?.(alertError);
this.onError?.(createError);
throw error;

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.

why do we not throw createError?

Pass onError through getOrCreateSandbox so only fresh creates notify the host, and throw the normalized createError.

Co-authored-by: Cursor <cursoragent@cursor.com>
@heerambavi1998

Copy link
Copy Markdown
Contributor

@thesujai lets either merge this or close this PR

This branch has not been deployed

No deployments
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.

3 participants