fix: persist Daytona authentication failures - #519
Conversation
🦋 Changeset detectedLatest commit: a1379ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 0b05405. Configure here.
290e8b8 to
a1379ae
Compare
|
Rebased onto the latest |

Summary
Persist Daytona 401/403 failures as a failed sandbox-provider status instead of returning an internal settings error or losing the typed error when sandbox execution converts it to a failed result.
Closes #516
Changes
status_reasonvaluestrueforgeandtrueforge-coreHow was this tested?
pnpm --filter @truefoundry/trueforge-core test -- --runInBand tests/core/sandbox/daytonaSnapshotRegistration.test.tspnpm --filter @truefoundry/trueforge test -- --runInBand tests/unit/sandbox/providerUtils.test.tspnpm --filter @truefoundry/trueforge test:store:sqlite -- --runInBand tests/db/sqlite/sandbox-provider-store/contract.test.tspnpm --filter @truefoundry/trueforge-core typecheckpnpm --filter @truefoundry/trueforge typecheckpnpm exec eslint packages/trueforge-core/src/core/sandbox/provider/DaytonaProvider.ts packages/trueforge/src/runtime/sessionResources.ts packages/trueforge/src/sandbox/providerUtils.tsgit diff --checkValidation is intentionally scoped to the two changed packages and the Daytona failure paths; full workspace build/test and live Daytona credential revocation were not run locally. The callback is optional and database write failures are logged without replacing the original provider result. The SQLite store contract was run locally; the equivalent Postgres contract was not run because no local Postgres service was started.
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changed (not applicable: no configuration or documented API change)Note
Medium Risk
Changes tenant sandbox-provider persistence and concurrency on status updates; mistakes could mark providers failed incorrectly or miss updates after credential rotation.
Overview
When Daytona returns 401 or 403 (including wrapped
Error.causechains), the sandbox provider row is updated tofailedwith stablestatus_reasontext instead of leaving a generic settings error or losing the signal whenexecturns errors into{ success: false }.DaytonaSandboxProvidergains an optionalonErrorhook invoked fromcreateSandbox(before rethrow) andexec(before returning a failed result). Runtime wiring insessionResourcescallsrecordDaytonaAccessFailure, which writes through the store.checkSnapshotStatususes the same path when snapshot refresh/build calls fail with auth errors.updateSandboxStatusnow accepts optionalexpected_manifestso status writes from an older credential/config snapshot are ignored if the tenant manifest changed concurrently; successful refresh updates pass the current manifest for the same guard.Reviewed by Cursor Bugbot for commit a1379ae. Bugbot is set up for automated code reviews on this repo. Configure here.