Skip to content

AGE-1831: enhance DaytonaSandboxProvider with build failure handling - #258

Open
thesujai wants to merge 2 commits into
mainfrom
bugfix/failed-on-build-failed
Open

AGE-1831: enhance DaytonaSandboxProvider with build failure handling#258
thesujai wants to merge 2 commits into
mainfrom
bugfix/failed-on-build-failed

Conversation

@thesujai

@thesujai thesujai commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

On build failure we will do a callback to fail in db

Changes

  • enhance DaytonaSandboxProvider with build failure handling

How was this tested?

Checklist

  • 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/sdk, .github/fern/openapi/openapi.json)
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
Changes sandbox provider configure/read paths and DB status persistence for Daytona builds; failures could affect tenant sandbox readiness but scope is limited to Daytona snapshot lifecycle.

Overview
Daytona sandbox image builds no longer block on the SDK’s snapshot.create, which polls until the snapshot is active or failed. buildImage now POSTs to Daytona’s /snapshots endpoint (register-only), maps the immediate response to pending/ready/failed, and treats 409 as “another replica started the build” instead of an error.

Configure (PUT) awaits that register call (still capped at ~3s), so auth failures surface on save while long image pulls stay observable via GET status checks.

GET status refresh only persists terminal ready or failed to the DB; transient pending is returned on the wire but not written back, avoiding stale pending rows.

Provider construction now passes apiKey and optional apiUrl for the direct HTTP register path. Unit tests cover register POST shape, conflict handling, and forbidden responses.

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

@thesujai thesujai changed the title feat: enhance DaytonaSandboxProvider with build failure handling AGE-1831: enhance DaytonaSandboxProvider with build failure handling Aug 14, 2026

@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 2 potential issues.

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 f49c37a. Configure here.

Comment thread packages/harness/src/core/sandbox/provider/DaytonaProvider.ts Outdated
Comment thread packages/server/src/sandbox/providerUtils.ts Outdated
return next;
// GET is a reader: it only persists terminal states (ready/failed) observed from Daytona.
// `pending` is transient and re-derived on every read, so never write it back.
if (next.status === 'pending') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should still persist. We can use db to serve in scenarios where Daytona endpoint becomes unavailable. Lets keep DB updated

logger: deps.logger,
...(locked ? { build_metadata: locked.build_metadata } : {}),
});
// Awaits register-only POST (~1s). Auth failures throw here → 422 below; progress is on GET.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not required

return this.toBuild(registered.state, registered.errorReason);
} catch (error) {
// A losing concurrent create is not a build failure: the winner owns the deterministic name.
if (error instanceof DaytonaError && error.statusCode === SNAPSHOT_CONFLICT_STATUS) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

catch 403?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also update get Status to catch 404?
Are we using SDK in get? or API

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