Repository navigation
Conversation
validate_relative_path used os.path.isabs, which only follows the host path flavour: on Windows the drive-less rooted forms /abs, /etc/passwd and \\\\abs all pass, and on POSIX a drive-prefixed C: path passes. Reject both flavours explicitly.
|
We require contributors to sign our Contributor License Agreement, and we don't have @DZH166 on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
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 found 2 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| # path flavour: a rooted or drive-prefixed source never resolves inside the | ||
| # context directory, and letting it through only defers the failure to the | ||
| # build's file-hash step. | ||
| if _is_absolute_path(src): |
There was a problem hiding this comment.
🟡 JavaScript copy paths remain host-dependent
On POSIX, Python copy() now rejects C:\Windows\file, but JavaScript copy() accepts it. JavaScript validateRelativePath still uses host-dependent path.isAbsolute, so equivalent SDK calls diverge.
Learn more
The SDKs share a template-copy contract. This change makes Python reject drive-prefixed sources on POSIX, but JavaScript validateRelativePath only calls the host-dependent path.isAbsolute. JavaScript copy passes its sources through that validator, so it still records a Windows source on POSIX.
Example: On Linux, Python copy('C:\\Windows\\file', '/app/') raises immediately. JavaScript copy('C:\\Windows\\file', '/app/') accepts the source and later fails when the build looks for files.
Recommended fix: Apply equivalent cross-flavour checks to JavaScript validateRelativePath and cover the same paths in its copy tests.
Was this helpful? React with 👍 or 👎 to provide feedback.
| # path flavour: a rooted or drive-prefixed source never resolves inside the | ||
| # context directory, and letting it through only defers the failure to the | ||
| # build's file-hash step. | ||
| if _is_absolute_path(src): |
There was a problem hiding this comment.
🟡 Copy behavior change lacks changeset
Python copy() now rejects sources it previously recorded, changing its public behavior. No changeset accompanies the SDK change, leaving the release without this fix.
Learn more
The new validator affects public Python copy and copy_items calls. These calls now raise immediately on Windows-shaped sources, instead of recording an instruction. The repository's changeset rule applies to public SDK surface changes, and this PR adds no changeset.
Example: A Linux user passing C:\\Windows\\file gets a TemplateException at copy() rather than an error during build; the release notes would omit the changed behavior.
Recommended fix: Generate a patch changeset for @e2b/python-sdk describing the new cross-platform path validation.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
TASTE.md review of the changed code. I checked parity (T-1, T-2), errors (T-59, T-62, T-63), client-side validation scope (T-52), and docstrings (T-69, T-71).
1 violation found:
- T-1 (inline): the stricter absolute-path check only exists in the Python SDK. JS
validateRelativePath(packages/js-sdk/src/template/utils.ts) still uses the host'spath.isAbsolute, so the two SDKs now accept differentcopy()sources.
Everything else is compliant. The check fits T-52(b): it turns a late, unrelated ValueError: No files found into an actionable error at the copy() call. The error message is unchanged and tells the user what to do (T-62/T-63). The :raises docstring is still in reST style (T-71). Sync and async share e2b/template/utils.py, so T-2 parity holds.
Not counted, because the lines are unchanged: this argument validation runs before any build starts but raises TemplateException, not InvalidArgumentException (T-59). The new tests lock that in with pytest.raises(TemplateException, ...), so a later move to InvalidArgumentException would need to update them.
| # path flavour: a rooted or drive-prefixed source never resolves inside the | ||
| # context directory, and letting it through only defers the failure to the | ||
| # build's file-hash step. | ||
| if _is_absolute_path(src): |
There was a problem hiding this comment.
T-1: JS, sync Python, and async Python must behave the same, not just share names. After this change, Python rejects drive-less rooted and drive-prefixed sources on every host. JS validateRelativePath in packages/js-sdk/src/template/utils.ts still calls host-flavoured path.isAbsolute(src), which gives:
| src | path.posix.isAbsolute |
path.win32.isAbsolute |
|---|---|---|
\a |
false | true |
\\srv\share |
false | true |
C:\Windows |
false | true |
C:foo |
false | false |
So Template().copy('C:\\Windows', '/app/') now throws in Python on Linux/macOS but still passes JS validation there. C:foo passes JS validation on every host. Please make the same change in the JS SDK in this PR, per the repo's AGENTS.md: "ensure equivalent changes are applied to both JS as well as sync and async Python implementations". For example:
function isAbsolutePath(src: string): boolean {
return (
path.posix.isAbsolute(src) ||
path.win32.isAbsolute(src) ||
/^[A-Za-z]:/.test(src)
)
}
// in validateRelativePath
if (isAbsolutePath(src)) {Add matching cases to the JS validateRelativePath tests too.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24d636a8c6
ℹ️ 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".
| # leaves these drive-less, so they need their own check. | ||
| or path.startswith("\\") | ||
| # Drive-prefixed path (`C:\foo`, `C:foo`). | ||
| or ntpath.splitdrive(path)[0] != "" |
There was a problem hiding this comment.
Mirror the new COPY validation in the JavaScript SDK
For C:drive-relative on either host platform, Python now raises TemplateException, but JS copy() still accepts the source because packages/js-sdk/src/template/utils.ts:37 only uses path.isAbsolute. Windows absolute and UNC sources are likewise still accepted by JS on POSIX. Apply the equivalent guard and regression tests in JS; otherwise this SDK change violates the cross-language equivalence requirement in AGENTS.md.
AGENTS.md reference: AGENTS.md:L3-L3
Useful? React with 👍 / 👎.
| # path flavour: a rooted or drive-prefixed source never resolves inside the | ||
| # context directory, and letting it through only defers the failure to the | ||
| # build's file-hash step. | ||
| if _is_absolute_path(src): |
There was a problem hiding this comment.
Add a changeset for the public copy-validation change
For callers of public Template.copy() and copy_items(), this changes accepted inputs and makes previously deferred failures raise TemplateException immediately. However, the commit adds no .changeset/*.md entry for @e2b/python-sdk, leaving this user-visible change unrecorded in the package's release/changelog metadata. Add the changeset required by AGENTS.md for changes to the SDK's public surface.
AGENTS.md reference: AGENTS.md:L6-L6
Useful? React with 👍 / 👎.
Problem
validate_relative_path()decides whether acopy()source is absolute with the host's path flavour:That misses the forms that can never resolve inside the template context directory:
ntpath.isabs()requires a drive, so the drive-less rooted forms/absolute/path,/,/etc/passwdand\absolute\pathall pass the guard (verified:os.path.isabs("/absolute/path") == Falseon Python 3.13/win32);C:\Windows\System32passes.The invalid COPY instruction is recorded silently, so the documented
TemplateExceptionnever fires for these inputs and the mistake only surfaces much later fromcalculate_files_hash()as an unrelatedValueError: No files found in /absolute/path.Fix
Reject both flavours explicitly: any leading
/or\(rooted, no drive needed), any drive-relative form (C:foo), and anyntpath/posixpathabsolute path - while keeping legitimate relative paths such asdir/file,./fileand..rejected/accepted exactly as before.Tests
tests/shared/template/utils/test_validate_relative_path.py(10 new cases, sync and async templates):Full offline suite: 855 passed, 33 skipped, 3 failed - the 3 failures are
OSError: [WinError 1314]fromos.symlink()in test setup and fail identically on the pristine tree.