Skip to content

Fix snapshot create sandbox org resolution#1438

Merged
jhaynie merged 1 commit intomainfrom
fix/snapshot-create-cache-target
May 2, 2026
Merged

Fix snapshot create sandbox org resolution#1438
jhaynie merged 1 commit intomainfrom
fix/snapshot-create-cache-target

Conversation

@jhaynie
Copy link
Copy Markdown
Member

@jhaynie jhaynie commented May 2, 2026

Summary

  • resolve the full sandbox target for cloud sandbox snapshot create instead of region only
  • pass the cached/resolved sandbox org ID to Catalyst so snapshot creation works when the selected org differs from the sandbox org

Reproduction

  • created a sandbox in org_38uEd1JNXIe89KMPaOwx1WJW43o while the selected profile org differed
  • cloud sandbox snapshot create <sandbox-id> --json returned 404
  • setting AGENTUITY_CLOUD_ORG_ID=org_38uEd1JNXIe89KMPaOwx1WJW43o made the same command succeed
  • after this change, the command succeeds without --org-id or AGENTUITY_CLOUD_ORG_ID by using the cached sandbox target

Verification

  • bunx biome check packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
  • live verified cloud sandbox snapshot create <sandbox-id> --json succeeds without --name and without org env when the sandbox target is cached

Notes

  • bun run --filter @agentuity/cli typecheck currently fails on unrelated coder workspace API/type mismatches from current origin/main (CoderUpdateWorkspaceRequest, updateWorkspace, refreshWorkspaceSnapshot, dependency/setupScript fields).
  • Test snapshot and sandbox created during reproduction were deleted.

Summary by CodeRabbit

  • Refactor
    • Improved sandbox target resolution in the cloud sandbox snapshot create command to better handle region and organization information.

@agentuity-agent
Copy link
Copy Markdown

agentuity-agent Bot commented May 2, 2026

The latest Agentuity deployment details.

Project Deployment Preview Updated (UTC)
docs 🟢 Ready (deploy_e83df98e6f1db5f60d8566a7c1e5e911) - 2026-05-02T16:59:49Z

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 88358935-54a2-484f-98df-de8fad3fa525

📥 Commits

Reviewing files that changed from the base of the PR and between 12634db and 8f1d339.

📒 Files selected for processing (1)
  • packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Build
  • GitHub Check: Storage CLI Tests
  • GitHub Check: Template Integration Tests
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Queue SDK Tests
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: Standalone Agent Test
  • GitHub Check: Pack & Upload
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Windows WSL CLI Smoke Test
  • GitHub Check: Agentuity Deployment
🧰 Additional context used
📓 Path-based instructions (3)
packages/cli/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

Use Bun.file(f).exists() instead of existsSync(f) for file existence checks

Files:

  • packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
🧠 Learnings (3)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
📚 Learning: 2026-01-13T04:32:02.691Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 565
File: packages/cli/src/cmd/cloud/region-lookup.ts:14-26
Timestamp: 2026-01-13T04:32:02.691Z
Learning: Enforce sandbox identifier prefixes in new code within the CLI cloud region lookup: new sandboxes must use the sbx_ prefix. The snbx_ prefix may appear in legacy code or examples, but do not use snbx_ for new sandboxes. When reviewing changes in packages/cli/src/cmd/cloud/, ensure any created sandbox identifiers use sbx_ and remove or migrate any snbx_ usages in newly added code.

Applied to files:

  • packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
📚 Learning: 2026-02-17T14:23:15.448Z
Learnt from: potofpie
Repo: agentuity/sdk PR: 974
File: packages/cli/src/cmd/git/account/list.ts:39-40
Timestamp: 2026-02-17T14:23:15.448Z
Learning: In the Agentuity CLI framework (packages/cli), when a subcommand declares requires: { auth: true }, the framework will automatically call requireAuth() before invoking the handler. Do not call requireAuth(ctx) manually inside command handlers. This applies to all TypeScript command files under packages/cli/src, including paths like packages/cli/src/cmd/git/account/list.ts.

Applied to files:

  • packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
🔇 Additional comments (3)
packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts (3)

6-6: Import update is correct for sandbox target resolution.

Good switch to resolveSandboxTarget alongside createSandboxClient; this matches the intended region+org resolution flow.


91-99: Sandbox target resolution wiring looks correct.

Using sandboxInfo.region to build the sandbox client is the right fix for cache-backed target routing.


107-107: Org ID selection now aligns with sandbox ownership.

Passing the resolved sandbox org into snapshotCreate is a solid fix for cross-org profile mismatch cases.


📝 Walkthrough

Walkthrough

The snapshot create command is refactored to use resolveSandboxTarget instead of getSandboxRegion, consolidating sandbox region and organization resolution into a single sandboxInfo object that supplies both region and orgId.

Changes

Sandbox Resolution Refactoring

Layer / File(s) Summary
Import Update
packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
getSandboxRegion replaced with resolveSandboxTarget in imports from ../util.
Handler Logic
packages/cli/src/cmd/cloud/sandbox/snapshot/create.ts
resolveSandboxTarget() call replaces getSandboxRegion(); sandbox client creation and snapshotCreate() now derive region and orgId (with fallback) from the returned sandboxInfo object.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Review rate limit: 0/5 reviews remaining, refill in 54 minutes and 31 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@jhaynie jhaynie linked an issue May 2, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

📦 Canary Packages Published

version: 2.0.12-8f1d339

Packages
Package Version URL
@agentuity/schedule 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-schedule-2.0.12-8f1d339.tgz
@agentuity/frontend 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-frontend-2.0.12-8f1d339.tgz
@agentuity/cli 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-cli-2.0.12-8f1d339.tgz
@agentuity/task 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-task-2.0.12-8f1d339.tgz
@agentuity/react 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-react-2.0.12-8f1d339.tgz
@agentuity/sandbox 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-sandbox-2.0.12-8f1d339.tgz
@agentuity/server 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-server-2.0.12-8f1d339.tgz
@agentuity/queue 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-queue-2.0.12-8f1d339.tgz
@agentuity/runtime 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-runtime-2.0.12-8f1d339.tgz
@agentuity/email 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-email-2.0.12-8f1d339.tgz
@agentuity/claude-code 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-claude-code-2.0.12-8f1d339.tgz
@agentuity/db 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-db-2.0.12-8f1d339.tgz
@agentuity/auth 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-auth-2.0.12-8f1d339.tgz
@agentuity/coder-tui 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-coder-tui-2.0.12-8f1d339.tgz
@agentuity/evals 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-evals-2.0.12-8f1d339.tgz
@agentuity/opencode 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-opencode-2.0.12-8f1d339.tgz
@agentuity/webhook 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-webhook-2.0.12-8f1d339.tgz
@agentuity/vector 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-vector-2.0.12-8f1d339.tgz
@agentuity/migrate 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-migrate-2.0.12-8f1d339.tgz
@agentuity/drizzle 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-drizzle-2.0.12-8f1d339.tgz
@agentuity/workbench 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-workbench-2.0.12-8f1d339.tgz
@agentuity/schema 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-schema-2.0.12-8f1d339.tgz
@agentuity/coder 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-coder-2.0.12-8f1d339.tgz
@agentuity/postgres 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-postgres-2.0.12-8f1d339.tgz
@agentuity/keyvalue 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-keyvalue-2.0.12-8f1d339.tgz
@agentuity/core 2.0.12-8f1d339 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-core-2.0.12-8f1d339.tgz
Install

Add to your package.json:

{
  "dependencies": {
    "@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-schedule-2.0.12-8f1d339.tgz",
    "@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-frontend-2.0.12-8f1d339.tgz",
    "@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-cli-2.0.12-8f1d339.tgz",
    "@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-task-2.0.12-8f1d339.tgz",
    "@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-react-2.0.12-8f1d339.tgz",
    "@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-sandbox-2.0.12-8f1d339.tgz",
    "@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-server-2.0.12-8f1d339.tgz",
    "@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-queue-2.0.12-8f1d339.tgz",
    "@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-runtime-2.0.12-8f1d339.tgz",
    "@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-email-2.0.12-8f1d339.tgz",
    "@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-claude-code-2.0.12-8f1d339.tgz",
    "@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-db-2.0.12-8f1d339.tgz",
    "@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-auth-2.0.12-8f1d339.tgz",
    "@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-coder-tui-2.0.12-8f1d339.tgz",
    "@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-evals-2.0.12-8f1d339.tgz",
    "@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-opencode-2.0.12-8f1d339.tgz",
    "@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-webhook-2.0.12-8f1d339.tgz",
    "@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-vector-2.0.12-8f1d339.tgz",
    "@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-migrate-2.0.12-8f1d339.tgz",
    "@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-drizzle-2.0.12-8f1d339.tgz",
    "@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-workbench-2.0.12-8f1d339.tgz",
    "@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-schema-2.0.12-8f1d339.tgz",
    "@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-coder-2.0.12-8f1d339.tgz",
    "@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-postgres-2.0.12-8f1d339.tgz",
    "@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-keyvalue-2.0.12-8f1d339.tgz",
    "@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-core-2.0.12-8f1d339.tgz"
  }
}

Or install directly:

bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-schedule-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-frontend-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-cli-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-task-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-react-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-sandbox-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-server-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-queue-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-runtime-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-email-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-claude-code-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-db-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-auth-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-coder-tui-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-evals-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-opencode-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-webhook-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-vector-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-migrate-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-drizzle-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-workbench-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-schema-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-coder-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-postgres-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-keyvalue-2.0.12-8f1d339.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-8f1d339/agentuity-core-2.0.12-8f1d339.tgz

@jhaynie jhaynie merged commit 682741e into main May 2, 2026
19 checks passed
@jhaynie jhaynie deleted the fix/snapshot-create-cache-target branch May 2, 2026 17:01
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.

Snapshot create fails with 500 when --name is omitted

1 participant