Skip to content

fix: disambiguate sync-from-public branch checkout#1235

Merged
notgitika merged 1 commit into
mainfrom
fix/sync-from-public-ambiguous-preview
May 13, 2026
Merged

fix: disambiguate sync-from-public branch checkout#1235
notgitika merged 1 commit into
mainfrom
fix/sync-from-public-ambiguous-preview

Conversation

@aidandaly24
Copy link
Copy Markdown
Contributor

Summary

The `Sync from Public Repo` workflow has been silently failing on every scheduled run (every 6h) since the public-origin branch collision started. This PR fixes the underlying `git` ambiguity.

Root cause

Each job runs:

```bash
git remote add public https://github.com/aws/agentcore-cli.git
git fetch public main # or 'preview'
...
git checkout main # ← ambiguous!
```

After fetching, both `origin` and `public` have a branch named `main` (and `preview`), so the DWIM shortcut `git checkout main` fails:

```
fatal: 'preview' matched multiple (2) remote tracking branches
##[error]Process completed with exit code 128.
```

Recent failures (all caused by this):

Fix

Replace `git checkout ` + `git reset --hard origin/` with `git checkout -B origin/` in both jobs. `-B` creates or resets the local branch from an explicit ref, sidestepping the DWIM ambiguity entirely and consolidating two steps into one.

Why now

Before the App-token rollout (5767d93), the same workflow already had this latent bug — but at that time the public mirror was lagging behind, so the `merge-base --is-ancestor` short-circuit kept hiding it. Once the repos drifted, every run started hitting the failed `checkout`.

Test plan

  • Merge and watch the next 6-hour scheduled run succeed (or fail with a different, real error)
  • If it now succeeds and main+public are already in sync, expect the `merge-base --is-ancestor` early-exit path to fire and the job to no-op

After 'git remote add public' fetches the same branches that already exist
on origin, 'git checkout <branch>' becomes ambiguous and fails with:

    fatal: 'preview' matched multiple (2) remote tracking branches

Both sync jobs now use 'git checkout -B <branch> origin/<branch>' which
explicitly resets the local branch from origin's tracking ref, removing
the ambiguity and combining the previous 'checkout + reset --hard' into
one step.

Last 4 scheduled runs of 'Sync from Public Repo' all failed with this
error; the workflow has been silently broken since the public/origin
branches collided.
@aidandaly24 aidandaly24 requested a review from a team May 13, 2026 18:21
@github-actions github-actions Bot added the size/xs PR size: XS label May 13, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.13.1.tgz

How to install

npm install https://github.com/aws/agentcore-cli/releases/download/pr-1235-tarball/aws-agentcore-0.13.1.tgz

Copy link
Copy Markdown

@agentcore-cli-automation agentcore-cli-automation left a comment

Choose a reason for hiding this comment

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

Looks good to merge. The diagnosis is accurate — git fetch public main populates refs/remotes/public/main (since git remote add installs the default +refs/heads/*:refs/remotes/public/* fetch refspec), so once both origin and public have a main/preview ref, DWIM git checkout <branch> becomes ambiguous and fails. git checkout -B <branch> origin/<branch> sidesteps DWIM by giving git an explicit start point, and it preserves the original semantics (force-create-or-reset local branch to origin/<branch>) while collapsing two commands into one. Symmetric application to both jobs is correct. No test or telemetry concerns since this is CI infra.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 43.31% 9097 / 21000
🔵 Statements 42.59% 9660 / 22679
🔵 Functions 40.17% 1577 / 3925
🔵 Branches 40.11% 5881 / 14660
Generated in workflow #2911 for commit d7a7798 by the Vitest Coverage Report Action

Copy link
Copy Markdown
Contributor

@notgitika notgitika left a comment

Choose a reason for hiding this comment

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

LGTM

@notgitika notgitika merged commit 9503239 into main May 13, 2026
26 checks passed
@notgitika notgitika deleted the fix/sync-from-public-ambiguous-preview branch May 13, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants