Skip to content

Conversation

@mishushakov
Copy link
Member

@mishushakov mishushakov commented Jan 6, 2026

Add handling for absolute paths (/home/users/mish/file.txt) and up dirs (../../file.txt)


Note

Adds robust path handling for file COPY/upload across JS and Python SDKs, enabling absolute (/) and parent-directory (../) sources with correct POSIX normalization and tar packaging.

  • Introduces rewriteSrc and toPosixPath; updates getAllFilesInPath to resolve absolute/.. paths and normalize separators
  • Switches JS tar creation to modern-tar with gzip stream; updates tarFileStream/tarFileStreamUpload and renames params to filePath
  • Extends instruction schema with filePath; uses it for hashing, uploads, and logs in both SDKs
  • Updates build/upload flow to preserve correct archive paths for absolute/.. sources
  • Adds comprehensive tests for rewriteSrc, tarFileStream, and build flows using absolute paths
  • Updates JS SDK deps (add modern-tar, move tar to dev)

Written by Cursor Bugbot for commit 451105a. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2026

🦋 Changeset detected

Latest commit: 451105a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Patch
e2b Patch

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

Copy link

@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: 044fc37498

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

# For paths outside of the context directory, return the full resolved path in POSIX format
if src.startswith(".."):
return to_posix_path(os.path.normpath(os.path.join(file_context_path, src)))
return src
Copy link

Choose a reason for hiding this comment

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

Python SDK path mismatch for relative context with .. paths

Medium Severity

The Python SDK's rewrite_src function uses os.path.normpath(os.path.join()) for .. paths, which preserves relative paths if file_context_path is relative. The JS SDK uses path.resolve() which always returns an absolute path. This causes a mismatch when file_context_path is relative: the Dockerfile COPY instruction would reference a relative path like config.txt while the tar archive stores the file at a fully resolved path like home/user/config.txt. The build would fail because the paths don't match. Using os.path.abspath instead of os.path.normpath(os.path.join()) would align the behavior with the JS SDK.

Fix in Cursor Fix in Web

if len(posix_path) >= 2 and posix_path[1] == ":":
posix_path = posix_path[2:]
# Strip leading slash
return posix_path.lstrip("/")
Copy link

Choose a reason for hiding this comment

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

Python lstrip strips all slashes vs JS single slash

Low Severity

The Python SDK's to_posix_path function uses lstrip("/") which removes all leading slashes, while the JS SDK uses replace(/^\//, '') which removes only one. For paths with multiple leading slashes (like UNC paths //server/share after backslash conversion), Python would return server/share while JS would return /server/share. This inconsistency could cause different tar archive structures between the SDKs when handling network paths or malformed paths with multiple leading slashes.

Fix in Cursor Fix in Web

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