Skip to content

Sample replay handler fails to find side-repo checkout because 'Configure Git credentials' overwrites origin URL #37545

@dsyme

Description

@dsyme

Summary

When a workflow uses checkout: to check out a non-workflow repository into $GITHUB_WORKSPACE, the compiled lockfile's "Configure Git credentials" step resets origin back to the workflow's own repository URL:

- name: Configure Git credentials
  env:
    REPO_NAME: ${{ github.repository }}   # <-- always the workflow repo
    SERVER_URL: ${{ github.server_url }}
    GITHUB_TOKEN: ${{ github.token }}
  run: |
    ...
    git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git"

The on-disk repo contents are the target repo (e.g. gh-aw-side-repo), but git config --get remote.origin.url returns the workflow repo (e.g. gh-aw-test).

This breaks downstream multi-repo detection in find_repo_checkout.cjs, which walks the workspace looking for a .git whose remote matches the target. The match always fails because the URL has been overwritten.

Reproduction

Trigger any workflow with safe-outputs.create-pull-request (or push-to-pull-request-branch) that uses checkout: to a different repo than github.repository, in sample-replay mode.

Example from githubnext/gh-aw-test:

Sample MCP server response:

[safeoutputs] Multi-repo mode: looking for checkout of githubnext/gh-aw-side-repo
git config --get remote.origin.url
Git command output: https://github.com/githubnext/gh-aw-test.git
[safeoutputs] Failed to find repo checkout: Repository 'githubnext/gh-aw-side-repo' not found in workspace.

The handler then returns an error-shaped MCP response, no safe-output is emitted, and Process Safe Outputs reports Found 0 message(s) in agent output.

Expected

Either:

  1. The "Configure Git credentials" step should not overwrite origin when the workspace is a checkout: of a different repo, or
  2. find_repo_checkout.cjs should consult the existing checkout-manifest.json (built earlier in the same job at line ~410 of the lockfile) rather than relying on git config --get remote.origin.url after a credentials step has potentially clobbered it.

The checkout manifest already contains the correct mapping (githubnext/gh-aw-side-repo -> path=), so option (2) is a localized fix.

Affected tests in githubnext/gh-aw-test

  • test-copilot-siderepo-create-pull-request
  • test-copilot-siderepo-create-pull-request-review-comment
  • test-copilot-siderepo-create-two-pull-requests

All produce Found 0 message(s) in agent output despite samples being declared.

Repro lockfile snippet

- name: Checkout repository
  uses: actions/checkout@... # gh-aw-test
- name: Checkout githubnext/gh-aw-side-repo
  uses: actions/checkout@... # overwrites workspace
- name: Build checkout manifest for safe-outputs handlers
  run: |
    # ... produces checkout-manifest.json mapping githubnext/gh-aw-side-repo -> path=""
- name: Configure Git credentials
  env:
    REPO_NAME: ${{ github.repository }}
  run: |
    git remote set-url origin "...github.com/${REPO_NAME}.git"  # <-- clobbers
- name: Replay safe-outputs samples (deterministic)
  # MCP server now sees origin=gh-aw-test, fails to find side-repo, returns error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions