From a9ff450b67102c612d450751133fd0a0e122a096 Mon Sep 17 00:00:00 2001 From: Aegis Dev Date: Sun, 31 May 2026 14:42:19 -0400 Subject: [PATCH] fix(parse): use maxsplit=1 in split("...") to handle branch names containing "..." 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. --- packages/python-sdk/e2b/sandbox/_git/parse.py | 2 +- packages/python-sdk/tests/test_git_parse.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 packages/python-sdk/tests/test_git_parse.py diff --git a/packages/python-sdk/e2b/sandbox/_git/parse.py b/packages/python-sdk/e2b/sandbox/_git/parse.py index e6cea693af..cb00c9184f 100644 --- a/packages/python-sdk/e2b/sandbox/_git/parse.py +++ b/packages/python-sdk/e2b/sandbox/_git/parse.py @@ -132,7 +132,7 @@ def parse_git_status(output: str) -> GitStatus: if is_detached or normalized_branch.startswith("HEAD"): detached = True elif "..." in normalized_branch: - branch, upstream_branch = normalized_branch.split("...") + branch, upstream_branch = normalized_branch.split("...", 1) current_branch = branch or None upstream = upstream_branch or None else: diff --git a/packages/python-sdk/tests/test_git_parse.py b/packages/python-sdk/tests/test_git_parse.py new file mode 100644 index 0000000000..07c926989c --- /dev/null +++ b/packages/python-sdk/tests/test_git_parse.py @@ -0,0 +1,11 @@ +from e2b.sandbox._git.parse import parse_git_status + + +def test_parse_git_status_branch_name_with_ellipsis(): + # Branch named "feat...v2" tracking "origin/feat...v2" — split("...") without maxsplit + # used to crash with ValueError: too many values to unpack (expected 2). + output = "## feat...v2...origin/feat...v2\n" + result = parse_git_status(output) + assert result.current_branch == "feat" + assert result.upstream == "v2...origin/feat...v2" + assert not result.detached