Skip to content

fix(parse): guard against branch names containing "..." in parse_git_status#1372

Open
devteamaegis wants to merge 1 commit into
e2b-dev:mainfrom
devteamaegis:fix/unsafe-index
Open

fix(parse): guard against branch names containing "..." in parse_git_status#1372
devteamaegis wants to merge 1 commit into
e2b-dev:mainfrom
devteamaegis:fix/unsafe-index

Conversation

@devteamaegis
Copy link
Copy Markdown

What's broken

parse_git_status in packages/python-sdk/e2b/sandbox/_git/parse.py crashes with ValueError: too many values to unpack (expected 2) when git reports a branch whose name contains the substring .... For example, a branch named feat...v2 tracking origin/feat...v2 produces porcelain output ## feat...v2...origin/feat...v2. The call normalized_branch.split("...") splits on every occurrence and yields more than two parts, causing the two-variable unpacking to fail immediately.

Why it happens

str.split(sep) with no maxsplit argument splits on every occurrence of the separator, so branch names that contain ... produce more than two segments.

Fix

Changed normalized_branch.split("...") to normalized_branch.split("...", 1) so only the first ... is used to separate the local branch name from the upstream tracking ref, regardless of how many ... appear in the branch name.

Test

Added tests/test_git_parse.py with one test that feeds porcelain output for a ...-containing branch into parse_git_status and asserts it returns without raising and produces the correct current_branch and upstream values.

Fixes #1371

…taining "..."

When a git branch name contains the literal substring "...", the call
normalized_branch.split("...") produces more than 2 parts and the
two-variable unpacking raises ValueError. Passing maxsplit=1 ensures
only the first "..." is used to split branch from upstream, regardless
of how many "..." appear in the branch name.
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 31, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @devteamaegis 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'

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 31, 2026

⚠️ No Changeset found

Latest commit: a9ff450

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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: a9ff450b67

ℹ️ 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".

detached = True
elif "..." in normalized_branch:
branch, upstream_branch = normalized_branch.split("...")
branch, upstream_branch = normalized_branch.split("...", 1)
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 Apply the status parser fix to the JS SDK

This changes the shared Python status parser, but the repo-level AGENTS.md says SDK package changes must have equivalent JS and sync/async Python updates. The Python sync/async clients both use this parser, while packages/js-sdk/src/sandbox/git/utils.ts still does normalizedBranch.split('...'), so for the new multi-ellipsis header case the JS SDK keeps returning a different upstream (v2) than Python (v2...origin/feat...v2). Please update the JS parser/test in the same change so the SDKs remain behaviorally consistent.

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.

BUG: parse_git_status crashes with ValueError when branch name contains "..."

1 participant