fix(daytona): omit resource fields when creating sandbox from snapshot - #2427
Open
pratikshabelwate05 wants to merge 1 commit into
Open
fix(daytona): omit resource fields when creating sandbox from snapshot#2427pratikshabelwate05 wants to merge 1 commit into
pratikshabelwate05 wants to merge 1 commit into
Conversation
DaytonaSandboxClientOptions initializes cpu=1, memory=1, disk=3 as non-null defaults. DaytonaHttp#createSandbox only skipped each field when null, so the defaults were always serialized into the request body -- even when a snapshot was specified. The Daytona API rejects resource parameters together with a snapshot (HTTP 400: 'Cannot specify Sandbox resources when using a snapshot'). Guard cpu/memory/disk behind !useSnapshot so they are only sent for image-based sandbox creation. The non-snapshot path is unchanged. Adds DaytonaHttpCreateSandboxTest to lock in both paths. Closes agentscope-ai#2421
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
oss-maintainer
approved these changes
Jul 28, 2026
oss-maintainer
left a comment
Collaborator
There was a problem hiding this comment.
Code Review — Approved ✅
Overall: Correct fix for #2421. The PR properly omits resource fields (cpu, memory, disk) when creating a sandbox from a snapshot, which aligns with the Daytona API's requirement that resource parameters cannot be specified together with a snapshot.
Key Changes:
- Modified
DaytonaSandboxClientOptionsto conditionally serialize resource fields - When a snapshot is specified, resource fields are omitted from the request body
- Added comprehensive test coverage for the snapshot creation scenario
Code Quality:
- ✅ Clean implementation with proper null checks
- ✅ Good test coverage
- ✅ Follows existing code patterns
CI Status: ✅ All checks passed
Verdict: Well-implemented fix that correctly addresses the reported issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Description
DaytonaHttp#createSandboxalways includescpu,memory, anddiskin the request body becauseDaytonaSandboxClientOptionsinitializes them to non-null defaults (1,1,3). When asnapshotis specified, the Daytona API rejects these resource parameters:Fixes #2421
Root Cause
DaytonaSandboxClientOptionsdefines:DaytonaHttp#createSandboxonly skips each field when it isnull. Since the defaults are non-null, they are always serialized — even in snapshot mode, where the Daytona API does not allow resource parameters.Fix
Guard
cpu/memory/diskbehind!useSnapshotso they are only included for image-based sandbox creation. The non-snapshot path is unchanged.This corresponds to Option A from the issue.
How to Verify
mvn test -pl agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-daytona -Dtest=DaytonaHttpCreateSandboxTestcreateSandbox_withSnapshot_omitsCpuMemoryDiskandcreateSandbox_withImage_includesCpuMemoryDiskTest Plan
DaytonaHttpCreateSandboxTest)mvn spotless:check+mvn testfor the module)Risk Assessment
Low — the change only removes fields from the request body in snapshot mode. The image-based path is byte-for-byte identical to before. No public API changes.