Skip to content

Commit c2a9830

Browse files
authored
Add CI repro test for GH_HOST proxy/PR checkout mismatch (issue #23461) (#23496)
1 parent 1e11f8b commit c2a9830

6 files changed

Lines changed: 98 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,3 +2991,96 @@ jobs:
29912991
echo "2. \`gh\` CLI calls are routed through the proxy (\`GH_HOST=localhost:18443\`)" >> $GITHUB_STEP_SUMMARY
29922992
echo "3. \`actions/github-script\` sees the proxy env (\`GH_HOST=localhost:18443\`)" >> $GITHUB_STEP_SUMMARY
29932993
echo "4. \`stop_difc_proxy.sh\` stops the proxy container" >> $GITHUB_STEP_SUMMARY
2994+
2995+
sh-gh-host-pr-checkout-repro:
2996+
name: GH_HOST Proxy PR Checkout Repro (Issue #23461)
2997+
runs-on: ubuntu-latest
2998+
timeout-minutes: 10
2999+
needs: validate-yaml
3000+
permissions:
3001+
contents: read
3002+
concurrency:
3003+
group: ci-${{ github.ref }}-sh-gh-host-pr-checkout-repro
3004+
cancel-in-progress: true
3005+
steps:
3006+
- name: Checkout code
3007+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3008+
3009+
- name: Start local proxy
3010+
run: |
3011+
# Start a simple HTTP server on port 19443 to simulate a local proxy.
3012+
# This is the "local proxy" referenced in the repro scenario for issue #23461:
3013+
# a server IS running on the proxy host, but git remotes still point to the real
3014+
# GitHub host, causing `gh pr checkout` to fail.
3015+
python3 -m http.server 19443 --bind 127.0.0.1 --directory /tmp >/tmp/local-proxy.log 2>&1 &
3016+
echo "LOCAL_PROXY_PID=$!" >> "$GITHUB_ENV"
3017+
sleep 1
3018+
echo "Local proxy started on port 19443 (simulating a DIFC-style proxy)"
3019+
3020+
- name: Set GH_HOST to simulate proxy-rewritten environment
3021+
run: |
3022+
# Set GH_HOST=localhost:19443 directly to simulate the proxy-rewritten environment
3023+
# described in issue #23461. We write directly to $GITHUB_ENV here because
3024+
# GITHUB_SERVER_URL is a runner-managed variable that cannot be overridden via
3025+
# step-level env:, so running configure_gh_for_ghe.sh with
3026+
# GITHUB_SERVER_URL=http://localhost:19443 would be silently ignored.
3027+
echo "GH_HOST=localhost:19443" >> "$GITHUB_ENV"
3028+
echo "Set GH_HOST=localhost:19443 (simulating a DIFC proxy-rewritten environment)"
3029+
3030+
- name: Repro - gh pr checkout fails when GH_HOST points to proxy without matching remote
3031+
env:
3032+
GH_TOKEN: ${{ github.token }}
3033+
run: |
3034+
echo "GH_HOST=${GH_HOST}"
3035+
echo "Git remotes (origin still points to github.com, not the local proxy):"
3036+
git remote -v
3037+
3038+
# Attempt gh pr checkout. GH_HOST=localhost:19443 but the only git remote
3039+
# is origin pointing to github.com — no remote matches the proxy host.
3040+
# gh CLI should exit non-zero with the characteristic mismatch error.
3041+
# Any PR number works here: gh validates GH_HOST against git remotes before
3042+
# making any API call, so the failure occurs regardless of whether PR #1 exists.
3043+
set +e
3044+
error_output=$(gh pr checkout 1 2>&1)
3045+
exit_code=$?
3046+
set -e
3047+
3048+
echo "gh pr checkout exit code: ${exit_code}"
3049+
echo "Output: ${error_output}"
3050+
3051+
if [ "${exit_code}" -eq 0 ]; then
3052+
echo "❌ Expected gh pr checkout to fail but it succeeded unexpectedly"
3053+
exit 1
3054+
fi
3055+
3056+
if echo "${error_output}" | grep -q "none of the git remotes"; then
3057+
echo "✅ Issue #23461 reproduced: GH_HOST mismatch causes gh pr checkout to fail"
3058+
echo " Error: ${error_output}"
3059+
else
3060+
echo "❌ gh pr checkout failed, but not with the expected GH_HOST/git remote mismatch error"
3061+
echo " Unexpected error output: ${error_output}"
3062+
exit 1
3063+
fi
3064+
3065+
- name: Stop local proxy
3066+
if: always()
3067+
run: |
3068+
if [ -n "${LOCAL_PROXY_PID:-}" ]; then
3069+
kill "${LOCAL_PROXY_PID}" 2>/dev/null || true
3070+
echo "Local proxy stopped"
3071+
fi
3072+
3073+
- name: Generate summary
3074+
if: always()
3075+
run: |
3076+
echo "## GH_HOST Proxy PR Checkout Repro (Issue [#23461](https://github.com/github/gh-aw/issues/23461))" >> $GITHUB_STEP_SUMMARY
3077+
echo "" >> $GITHUB_STEP_SUMMARY
3078+
echo "This test reproduces the failure mode described in issue #23461:" >> $GITHUB_STEP_SUMMARY
3079+
echo "" >> $GITHUB_STEP_SUMMARY
3080+
echo "1. A local HTTP server starts on \`localhost:19443\` (the \"local proxy\")" >> $GITHUB_STEP_SUMMARY
3081+
echo "2. \`configure_gh_for_ghe.sh\` sets \`GH_HOST=localhost:19443\` (simulating a proxy-rewritten environment)" >> $GITHUB_STEP_SUMMARY
3082+
echo "3. Git remote \`origin\` still points to the real GitHub host (not the proxy)" >> $GITHUB_STEP_SUMMARY
3083+
echo "4. \`gh pr checkout\` fails because no git remote matches \`GH_HOST\`" >> $GITHUB_STEP_SUMMARY
3084+
echo "" >> $GITHUB_STEP_SUMMARY
3085+
echo "The existing \`sh-difc-proxy\` job uses the full Docker-based DIFC proxy; this job" >> $GITHUB_STEP_SUMMARY
3086+
echo "provides a lightweight local-proxy repro that does not require Docker." >> $GITHUB_STEP_SUMMARY

.github/workflows/mcp-inspector.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-claude.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-codex.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot-arm.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)