Repository navigation
Description
What happened?
TrueForge 0.1.4 reports a valid, usable Daytona API key as invalid when the key can create/delete sandboxes but does not carry Daytona's separate write:snapshots permission.
I hit this while proving the sandbox path for a TrueForge hackathon project. The same key produced these direct Daytona results:
GET /api/sandbox -> 200
POST /api/sandbox -> 200 (sandbox created)
DELETE /api/sandbox/{id}?force=true -> 200
GET /api/snapshots/{missing-name} -> 404 (authenticated not-found)
POST /api/snapshots -> 403 { "message": "Access denied" }
But a schema-valid request to:
PUT /api/v1/settings/sandbox-providers
returns:
422 Daytona rejected the API key — check the credentials
The credential is not rejected. Its sandbox permission works; snapshot registration is forbidden.
The cause is visible in the 0.1.4 path:
- sandbox-provider setup calls
provider.buildImage(); DaytonaSandboxProvider.buildImage()registers the bundled image withPOST /snapshotswhen the deterministic snapshot does not exist;- a Daytona
403is classified byisDaytonaAuthError()alongside401and rewritten as a bad-key message.
Daytona's bundled SDK models write:snapshots separately from write:sandboxes, so this is an insufficient-permission result, not invalid authentication.
Reproduction
- Create a Daytona API key that can write/delete sandboxes but cannot write snapshots.
- Confirm that the key can create and delete a sandbox directly.
- Configure a Daytona sandbox provider in TrueForge 0.1.4 with that key.
- Observe the 422 bad-credential response.
- Send the same snapshot registration request directly and observe the underlying
403 Access denied.
No key value is needed in logs; HTTP status and the redacted error body are sufficient.
Expected behavior
- Distinguish
401 invalid credentialfrom403 authenticated but insufficient permission. - Name the required Daytona permission (
write:snapshots) in the API/UI error, or document it next to the API-key field. - Ideally, consider a direct-image fallback when
write:sandboxesis available butwrite:snapshotsis not. With the same key,daytona.create({ image: <TrueForge bundled image> })successfully created a sandbox, executedpython -c "print(17*19)"with exit 0/result 323, and deleted it. A local compatibility patch using that path also completed the full TrueForge turn:
truefoundry-system exec call
-> sandbox.created (Daytona)
-> tool.response { success: true, exitCode: 0, result: "323\n" }
-> turn.done / DAYTONA_OK:323
If snapshot registration is intentionally mandatory, the first two bullets still prevent a valid key from being blamed for a missing scope.
Environment
- TrueForge: 0.1.4, standalone/SQLite
@daytona/sdk: 0.204.1 (bundled by TrueForge)- Daytona API response version observed: 0.207.0
- Node.js: 24.14.1
- npm: 11.11.0
- macOS
Related but not duplicate: #417 covers missing timeouts on the snapshot-registration request. This report is about permission classification and the forced snapshot-write requirement.
Activity
keniel13-ui commentedon Aug 26, 2026
Follow-up: the permission diagnosis is now directly confirmed rather than inferred from the 403.
GET /api/api-keys/currentfor the original working-sandbox/failing-snapshot key returned this permission array (key value omitted):write:snapshotswas absent.GET /api/snapshotsstill returned 200, so snapshot read access was available while snapshot registration was not.A replacement key carrying exactly:
was then tested against unmodified TrueForge 0.1.4:
The sandbox was deleted afterward. No compatibility patch was involved in this second run.
That narrows the requested fix: direct-image fallback is optional, but the current
403mapping should not say the key is invalid. It should report that the authenticated key is missing the requiredwrite:snapshotspermission, and the settings UI/docs should name that required scope.thesujai commentedon Aug 27, 2026
Thanks @keniel13-ui, I agree here. The error should have been a 403 instead of a 422.
https://github.com/truefoundry/trueforge/blob/main/packages/trueforge/src/apis/sandboxProviders.ts#L107 should have returned the error's message here(if they are readable), else can do a further if for seperating 401 from 403.
Keeping this open for community contribution
ethanstoner commentedon Aug 27, 2026
@thesujai I'd like to pick this up, scoped to the classification fix you described — not the direct-image fallback in the third bullet, which reads as a product decision about whether snapshot registration stays mandatory.
Confirmed on
main.isDaytonaAuthErrorcollapses both statuses into one branch:so
PUT /api/v1/settings/sandbox-providersanswers422 "Daytona rejected the API key — check the credentials"both for an invalid key and for a valid key missingwrite:snapshots.On your suggestion to return the error's message at L107: I'd lean against reflecting Daytona's message verbatim. For this case it is just
"Access denied", which does not name the missing scope and so does not actually tell the operator what to fix — and reflecting a third-party error into a response is the pattern already flagged in #422. Splitting the statuses and writing our own message gets the operator the scope name and keeps the upstream body out of the response. Concretely:write:snapshotsas the required Daytona permission.tests/unit/apis/sandboxProviders.test.tsto cover the two statuses separately.Two things that are your call before I start:
'PUT does not persist config when the build call fails auth'asserts 422 for aDaytonaError(403)today. That test's real subject is the non-persistence, which I'd keep; only the status line moves. If you'd rather the status stay 422 and only the message improve, that's a smaller diff and I'll do that instead.Could you assign it to me if the scope looks right?
docs: README setup steps and real Qodo evidence
satvik8954 commentedon Aug 30, 2026
Ran into this exact issue tonight while building a hackathon project — same 422 "invalid key" response from TrueForge despite the key working fine directly against Daytona's API. Confirms this isn't an isolated case. Thanks for the thorough diagnosis and fix in #477.