Repository navigation
fix(sandbox): unique app name for same-name creates in the same second - #127
Merged
Merged
Conversation
The app holding a sandbox was named sandbox-app-<name>-<seconds>. App names are unique per organization, so two creates with the same name in the same second (parallel creates, or two processes in one organization) failed with 400 "name already exists". Use the time in base 36 plus 4 random characters: the same 10 characters as before, so every name that fit the 64-character limit still fits.
bchatelard
marked this pull request as ready for review
November 17, 2026 15:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Two
Sandbox.create()calls with the samenamein the same second can fail with400 name already exists. Theapp holding each sandbox is named
sandbox-app-<name>-<int(time.time())>, and app names are unique perorganization. Parallel creates hit this, and so do two processes creating sandboxes in one organization, like test
jobs whose examples use fixed names. The JavaScript SDK had the same bug at millisecond resolution and fixed it in
koyeb/koyeb-sandbox-sdk-js#60 .
What changed
SandboxSpec.app_payload()names the appsandbox-app-<name>-<suffix>. The suffix is the time in seconds inbase 36, followed by 4 random characters from
secrets.64-character app name limit still fits.
million.
Behavior change: the app name's suffix is no longer the Unix timestamp. Anything parsing the creation time out
of the app name would need the base-36 decode. The SDK itself never reads it back.
How it was verified
test_app_name_differs_for_same_name_creates_in_the_same_second. It freezestime.time(), builds 20payloads for a 41-character name (the longest that fit before), and checks that all 20 differ, are at most 64
characters and are valid app names. It fails on
main(1 != 20) and passes here.pytest koyeb/sandbox: 650 passed, 8 subtests passed.black --checkandflake8 --select=E9,F63,F7,F82(the CI lint) are clean on both changed files.