Add list and runtime APIs#8
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 57 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds sandbox and snapshot listing APIs with Zod schemas/types, new list methods on service clients, sandbox instance helpers for user home/workdir retrieval, and corresponding tests. Changes
Sequence Diagram(s)sequenceDiagram
participant SandboxInst as Sandbox (instance)
participant SandboxesSvc as SandboxesClient
participant Transport as Transport
participant API as API Server
SandboxInst->>SandboxesSvc: getWorkdir(id, options)
SandboxesSvc->>Transport: GET /v1/sandbox/{id}/system/workdir (query/options)
Transport->>API: HTTP request
API-->>Transport: { "workdir": "/home/user" }
Transport-->>SandboxesSvc: response JSON
SandboxesSvc-->>SandboxInst: "/home/user"
sequenceDiagram
participant Caller as Caller (app)
participant SandboxesSvc as SandboxesClient
participant Transport as Transport
participant API as API Server
Caller->>SandboxesSvc: list(params, options)
SandboxesSvc->>SandboxesSvc: validate params (Zod)
SandboxesSvc->>Transport: GET /v1/sandboxes?state=...&order-by=...&page-size=...
Transport->>API: HTTP request
API-->>Transport: { "items":[{...}], "total_items": 42 }
Transport-->>SandboxesSvc: response JSON
SandboxesSvc->>SandboxesSvc: normalize to ListSandboxesResponse (camelCase)
SandboxesSvc-->>Caller: { items: [...], totalItems: 42 }
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/models/index.ts`:
- Around line 5-10: The models barrel is missing runtime schemas for list
responses; add exports for the runtime schema symbols (e.g.,
listSandboxesResponseSchema and listSnapshotsResponseSchema) alongside the
existing exports (createSandboxParamsSchema, listSandboxesParamsSchema,
NetworkPolicyMode, SandboxState) so consumers can import both types and runtime
validators from the public models barrel; update the export statement to include
the list response schema names that are defined in the sandbox module.
In `@src/services/sandboxes.ts`:
- Around line 214-223: The code assumes the JSON response is an object and
directly accesses data.user_home_dir, which can throw if the server returns null
or a primitive; update the code that calls this.transport.requestJson (the block
using sandboxIdOf(sandbox)/system/user-home-dir) to first verify that the
returned value is a non-null object (e.g., typeof data === "object" && data !==
null) before accessing properties and only then check typeof data.user_home_dir
=== "string", otherwise throw the Leap0Error; apply the same guard to the
analogous block around the later request (the one noted at lines 235-244) that
reads other response fields so both locations validate the response shape before
property access.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 975c429e-c79e-4b65-891a-3be7b55c1eb2
📒 Files selected for processing (10)
src/client/sandbox.tssrc/index.tssrc/models/index.tssrc/models/sandbox.tssrc/models/snapshot.tssrc/services/sandboxes.tssrc/services/snapshots.tstests/client/client-sandbox.test.tstests/services/sandboxes-client.test.tstests/services/snapshots.test.ts
|
@CodeRabbit review? |
|
✅ Actions performedReview triggered.
|
Summary
Testing
Summary by CodeRabbit