fix sandbox create idempotency key#678
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59cc9d3f80
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
|
|
||
| def _clear_generated_create_idempotency_key(request: CreateSandboxRequest) -> None: | ||
| if request.idempotency_key is None: |
There was a problem hiding this comment.
Reset generated key when idempotency key is empty
_create_idempotency_key treats request.idempotency_key as absent when it is an empty string (""), but _clear_generated_create_idempotency_key only clears when it is exactly None. In that input case, a generated key is reused across all later successful create calls with the same request object, so distinct creates can be deduplicated unexpectedly and return the earlier sandbox. Align the clear condition with the generation condition (or validate non-empty idempotency keys) to avoid sticky keys.
Useful? React with 👍 / 👎.
Note
Medium Risk
Changes how
creategenerates and persistsidempotency_keyacross transient failures; if incorrect, could cause unintended duplicate sandbox creation or prevent legitimate retries. Scope is limited to sandbox create payload construction and associated tests.Overview
Fixes sandbox creation idempotency so automatic idempotency keys are stable across a failed
createretry.CreateSandboxRequestnow stores a private_generated_idempotency_key, and sync/asyncSandboxClient.create()uses a helper to reuse the same generated key until a successful response clears it (while still honoring user-suppliedidempotency_key). Adds coverage to ensure key reuse after a failure and key rotation on subsequent successful creates.Reviewed by Cursor Bugbot for commit 59cc9d3. Bugbot is set up for automated code reviews on this repo. Configure here.