Skip to content

fix(server): return already_exists for duplicate sandbox names#695

Open
drew wants to merge 1 commit intomainfrom
691-duplicate-sandbox-name-error/an
Open

fix(server): return already_exists for duplicate sandbox names#695
drew wants to merge 1 commit intomainfrom
691-duplicate-sandbox-name-error/an

Conversation

@drew
Copy link
Copy Markdown
Collaborator

@drew drew commented Mar 31, 2026

Summary

Return a proper AlreadyExists gRPC status when creating a sandbox with a duplicate name, instead of leaking a raw SQLite UNIQUE constraint failed error as an Internal status.

Related Issue

Closes #691

Changes

  • crates/openshell-server/src/grpc.rs: Added a get_message_by_name::<Sandbox> pre-check before put_message in create_sandbox, following the identical pattern used by create_provider. Returns Status::already_exists("sandbox '<name>' already exists") when a duplicate is found.
  • crates/openshell-cli/src/run.rs: Handle AlreadyExists status in the sandbox create path to show a user-friendly message with a hint to delete or rename.
  • e2e/python/test_inference_routing.py: Removed the workaround that matched INTERNAL status with "UNIQUE constraint failed" in the error string—now only ALREADY_EXISTS is needed.

Testing

  • mise run pre-commit passes
  • Unit tests pass (cargo test --workspace)
  • E2E tests added/updated (not applicable—existing e2e coverage was simplified, not expanded)

Checklist

  • Follows Conventional Commits
  • Architecture docs updated (not applicable)

Check for existing sandbox name before persisting, matching the
provider-creation pattern. The CLI now surfaces a clear hint instead
of a raw UNIQUE constraint error.

Closes #691
@drew drew requested a review from a team as a code owner March 31, 2026 06:20
@drew drew self-assigned this Mar 31, 2026
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.

bug(cli): sandbox create with duplicate name returns raw database error instead of user-friendly message

1 participant