Repository navigation
fix(python-sdk): percent-encode IDs in request paths - #2184
mishushakov wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 2eddfff The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 2eddfff. Bugbot is set up for automated code reviews on this repo. Configure here. |
Package ArtifactsBuilt from a38d0d4. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-dockerfile-utils-0.1.3-mishushakov-python-encode-path-ids.0.tgz ./e2b-2.67.1-mishushakov-python-encode-path-ids.0.tgzCLI ( npm install ./e2b-cli-2.26.1-mishushakov-python-encode-path-ids.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.9.2-mishushakov-python-encode-path-ids.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.5.1-mishushakov-python-encode-path-ids.0.tgzPython SDK ( pip install ./e2b_dockerfile_utils-0.1.2+mishushakov.python.encode.path.ids-py3-none-any.whl ./e2b-2.67.0+mishushakov.python.encode.path.ids-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.11.13+mishushakov.python.encode.path.ids-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.7.2+mishushakov.python.encode.path.ids-py3-none-any.whl |
There was a problem hiding this comment.
TASTE.md review of the Python path-ID encoding change.
Checked: T-1 (cross-SDK parity), T-2 (sync/async mirrors), T-52 (client-side validation only to prevent footguns), T-59 (InvalidArgumentException for pre-flight argument checks), T-62 / T-69 (documented failure modes), T-63 (error messages use the user's argument names).
Violations: 2
- T-1, inline on both volume files:
Volume.read_file(sync and async) still writesself._volume_idraw into a hand-built URL. Python still doesn't match JS for volume reads. - T-62 / T-69 (document when an error is thrown; every public method documents its failure modes):
Sandbox.kill,set_timeout,pause,get_info,connect,Secret.update/get_info/destroy, andVolume.get_info/connect/destroynow raiseInvalidArgumentExceptionfor"",".",".."or a non-string ID. Their docstrings don't mention it. For example,Sandbox.killstill says only:return: True if the sandbox was killed, False if the sandbox was not found. Add a line such as:raises InvalidArgumentException: whensandbox_idis empty,.or...to each method, in both sync and async. Those docstrings aren't in the diff, so this one has no inline comment.
Compliant: the new check raises InvalidArgumentException (T-59), it only guards a footgun the backend can't see once the URL has collapsed (T-52a), its message names the Python argument (sandbox_id, secret, volume_id) (T-63), and every changed call site appears identically in both the sync and async files (T-2).
The generated API client writes a path parameter into the URL as given,
so an ID with a separator named a different route:
Sandbox.kill("../templates/x") sent DELETE /templates/x. Template calls
already encoded their IDs; sandbox, snapshot, volume, secret and build
IDs now go through encode_path_param too, including the URL that
Volume.read_file builds by hand. encode_path_param also refuses an empty
value and dot segments, which escaping cannot keep in place.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
30d69e8 to
14639b5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 14639b5. Configure here.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🔍 Devin Review: 3 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
…mplate refusal A uuid.UUID passed as an ID was written into the URL as its text before the encoding was added; refuse only None, an empty value and dot segments. Name template names and IDs in the changeset and docstrings, since the refusal in encode_path_param covers them too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

The generated Python API client writes a path parameter into the URL as it is given, so an ID with a separator names a different route:
An application that passes an ID from its own users to the Python SDK lets that user reach other routes with the application's API key. Template IDs and names were already encoded, and the JS SDK encodes every path parameter.
Change
Sandbox, snapshot, volume, secret and build IDs now go through
encode_path_paramin the sync and the async SDK. That includesVolume.read_file, which builds its URL by hand, andSandbox.set_paused_retention. It percent-encodes the value into one path segment and refuses an empty value,.,..andNonewithInvalidArgumentException, since encoding cannot keep those in place. Any other value that is not a string, such as auuid.UUID, is sent as its text, as before.The refusal also reaches template names and IDs, which already went through
encode_path_param:Template.exists("")now raises instead of sending a request to another route.Review notes
Volume.read_filewas missed at first because it does not go through the generated client (found by Devin and Bugbot). The URL is now built before the stream, so an unusable ID on a streamed read is refused when the method is called. Methods that take a caller-supplied ID document the refusal with a:raisesline.tests/recording_backend.py), for both SDK flavours. Each was seen failing without its fix..or..yet; that check for JS is part of feat(sdk): refuse arguments the server never sees as given #2183.kill,set_timeout,set_paused_retentionandget_metricsreturn before the ID is checked whendebugis on, as Bugbot noted. No request is sent on that path, and validation in debug mode is tracked separately in SDK-403, so it is left as it is here.encode_path_param, with identical content, so they merge in either order without conflicts.Linear: SDK-456
🤖 Generated with Claude Code