Skip to content

fix(python-sdk): report unmerged AA/DD entries as git conflicts - #2165

Open
DZH166 wants to merge 1 commit into
e2b-dev:mainfrom
DZH166:fix/report-unmerged-aa-dd-entries-as-git
Open

DZH166 wants to merge 1 commit into
e2b-dev:mainfrom
DZH166:fix/report-unmerged-aa-dd-entries-as-git

Conversation

@DZH166

@DZH166 DZH166 commented Nov 21, 2026 •

Copy link
Copy Markdown

Problem

Sandbox.git.status() and AsyncSandbox.git.status() parse git status --porcelain=1 -b
with _derive_status in packages/python-sdk/e2b/sandbox/_git/parse.py. That function
classified a path as a conflict only when one of the two porcelain characters was U.

git-status(1) lists seven pairs for an unmerged path: DD, AU, UD, UA, DU, AA,
UU. Two of them, AA (both added) and DD (both deleted), contain no U, so a merge
stopped on one of those conflicts was reported as if it had no conflict at all:

$ git merge other
CONFLICT (add/add): Merge conflict in conflict.txt
$ git status --porcelain=1 -b
## main
AA conflict.txt
status = sandbox.git.status(repo_path)
status.has_conflicts   # False
status.conflict_count  # 0
status.file_status[0].status  # 'added'

Callers that gate a commit, a rebase or a "resolve the conflicts" step on has_conflicts
therefore proceeded as if the working tree were clean of conflicts, and the entry was
reported with the wrong label. DD was reported as deleted in the same way.

Fix

_derive_status now matches the porcelain pair against the set of unmerged pairs from
git-status(1) before the per-character rules, so AA and DD map to conflict like the
five pairs that contain a U. Pairs that are not unmerged keep their existing labels: a
staged add (A ) is still added and a deleted path ( D) is still deleted, because the
single characters are only matched after the pair check.

AA conflict.txt now yields:

status.file_status[0].status  # 'conflict'
status.has_conflicts          # True
status.conflict_count         # 1

The porcelain parsing is shared by Sandbox.git and AsyncSandbox.git, so both flavors are
fixed. A patch changeset is included.

Tests

  • packages/python-sdk/tests/test_git_conflict_status.py (new, offline): every unmerged
    pair from git-status(1) is reported as conflict with has_conflicts true and
    conflict_count 1, a two-entry conflicted merge is counted as two, and the pairs that are
    not unmerged (A , D, M , M, R , C , T , aa) keep their labels with
    conflict_count 0. 16 passed.
  • packages/python-sdk/tests/shared/git (nearest existing module, live-sandbox suite gated
    behind ENABLE_GIT_TESTS): 31 skipped, unchanged.
  • Offline SDK subset (tests/shared plus the unit modules at the tests root): 610 passed,
    33 skipped, and the 6 failures that predate this change on Windows (symlink creation
    privileges, ntpath absolute-path semantics) are identical before and after.

repro-1.py exits 1 on the unpatched tree with six failed assertions (both entries labeled
added/deleted, has_conflicts false, conflict_count 0) and exits 0 with the fix.


Devin Review

@DZH166
DZH166 requested a review from mishushakov as a code owner November 21, 2026 15:21
@cla-bot

cla-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

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'

@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc6657a

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

This PR includes changesets to release 1 package
Name Type
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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T15:25:11.019893Z dc6657a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TASTE.md review. Checked: parity (T-1, T-2), result labels and enums (T-15, T-16), errors (T-57 to T-63), docstrings (T-69, T-71), changeset and test placement.

1 violation, T-1 (JS / sync Python / async Python mirror 1:1 in semantics). The Python fix is correct, and because parse.py is shared, sync and async Python both get it (T-2 holds). The JS SDK has the same bug and this PR leaves it alone. deriveStatus in packages/js-sdk/src/sandbox/git/utils.ts (around line 332) still does if (statuses.has('U')) return 'conflict'. After this change, sandbox.git.status() in JS still reports AA/DD as added/deleted with hasConflicts === false, while Python reports conflict. The JS file is not in the diff, so the details are in the body and on the inline comment. Please add the same pair check in JS, add a matching unit test, and include 'e2b': patch in the changeset.

No other violations in the changed lines. Adding _UNMERGED_STATUS_PAIRS as a named module constant is the right shape.

Written by Devin

Comment on lines +81 to 82
if index_status + working_status in _UNMERGED_STATUS_PAIRS:
return "conflict"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

T-1: JS, sync Python and async Python must match 1:1 in semantics. This fixes Python only. JS deriveStatus in packages/js-sdk/src/sandbox/git/utils.ts still checks only for 'U', so the two SDKs now disagree about AA/DD. The compliant form is the same check in JS:

const UNMERGED_STATUS_PAIRS = new Set(['DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU'])

function deriveStatus(indexStatus: string, workingStatus: string): GitStatusLabel {
  if (UNMERGED_STATUS_PAIRS.has(indexStatus + workingStatus)) return 'conflict'
  const statuses = new Set([indexStatus, workingStatus])
  if (statuses.has('R')) return 'renamed'
  // ...
}

Add a JS unit test that mirrors test_git_conflict_status.py, and add 'e2b': patch to the changeset.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

"""
statuses = {index_status, working_status}
if "U" in statuses:
if index_status + working_status in _UNMERGED_STATUS_PAIRS:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Merge conflict detection differs across SDKs

For AA or DD entries, JavaScript’s deriveStatus still requires U and reports an addition or deletion. Python reports a conflict, while JavaScript reports none when those are the only conflicts.

Learn more

The SDK parity rule requires equivalent changes in JavaScript and both Python implementations. JavaScript’s status method reads the same Git porcelain format, but deriveStatus still recognizes conflicts only when a status character is U. Its conflict summary counts only entries labeled conflict.

Example: Both branches add settings.json differently, so Git reports AA settings.json. Python now reports one conflict. JavaScript labels the file added and reports zero conflicts if no other files are unmerged.

Recommended fix: Apply the same seven-pair check before JavaScript’s per-character rules, add coverage for AA and DD, and include the JavaScript SDK in the patch changeset.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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

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

Comment on lines +81 to 82
if index_status + working_status in _UNMERGED_STATUS_PAIRS:
return "conflict"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Mirror the conflict-pair check in the JavaScript SDK

For the AA/DD cases covered here, this changes Python's results but leaves JavaScript returning added/deleted with hasConflicts: false and conflictCount: 0: packages/js-sdk/src/sandbox/git/utils.ts:326-336 still recognizes conflicts only through U, and the public status method uses that parser. Mirror the pair check and regression coverage in JS so conflict reporting remains consistent across SDKs. The root AGENTS.md explicitly requires equivalent changes across JS and sync/async Python implementations.

AGENTS.md reference: AGENTS.md:L3-L3

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

1 participant