Skip to content

fix sandbox create idempotency key#678

Open
kcoopermiller wants to merge 1 commit into
mainfrom
fix/idempotent-key
Open

fix sandbox create idempotency key#678
kcoopermiller wants to merge 1 commit into
mainfrom
fix/idempotent-key

Conversation

@kcoopermiller
Copy link
Copy Markdown
Member

@kcoopermiller kcoopermiller commented May 20, 2026

Note

Medium Risk
Changes how create generates and persists idempotency_key across 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 create retry.

CreateSandboxRequest now stores a private _generated_idempotency_key, and sync/async SandboxClient.create() uses a helper to reuse the same generated key until a successful response clears it (while still honoring user-supplied idempotency_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.

@kcoopermiller kcoopermiller marked this pull request as draft May 20, 2026 20:09
@kcoopermiller kcoopermiller reopened this May 20, 2026
@kcoopermiller kcoopermiller marked this pull request as ready for review May 20, 2026 20:30
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

2 participants