Skip to content

Fix GH_AW_BIN detection failure under bash -e/pipefail#28339

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-binary-copy-logic-failure
Apr 24, 2026
Merged

Fix GH_AW_BIN detection failure under bash -e/pipefail#28339
pelikhan merged 5 commits intomainfrom
copilot/fix-binary-copy-logic-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

The "Install gh-aw extension" step in compiled lock files fails with Failed to find gh-aw binary for MCP server even when the binary is installed, because gh-aw is a gh extension (not on $PATH) and the single-line || fallback is unreliable under bash -e + set -o pipefail.

Changes

  • pkg/workflow/mcp_setup_generator.go — fix the code generator that emits the binary detection logic into compiled lock files
  • .github/workflows/shared/mcp/gh-aw.md — same fix in the shared component used by workflows with imports: uses: shared/mcp/gh-aw.md
  • smoke-copilot.golden + lock files — recompiled to reflect the updated logic

Before:

GH_AW_BIN=$(which gh-aw 2>/dev/null || find ~/.local/share/gh/extensions/gh-aw -name 'gh-aw' -type f 2>/dev/null | head -1)

After:

GH_AW_BIN=""
GH_AW_BIN=$(command -v gh-aw 2>/dev/null) || true
if [ -z "$GH_AW_BIN" ]; then
  GH_AW_BIN=$(find "${HOME}/.local/share/gh/extensions/gh-aw" -name 'gh-aw' -type f 2>/dev/null | head -1) || true
fi

The || true guards ensure a non-zero exit from binary lookup and a broken-pipe from find | head -1 don't abort the step under errexit/pipefail. command -v (a POSIX shell built-in) is used instead of which so detection works even in minimal container environments where which may not be installed.


Changeset

  • Type: patch
  • Description: Fix gh-aw binary detection in generated MCP setup steps so runs do not fail under bash -e and set -o pipefail when the extension binary is installed outside $PATH.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • ab.chatgpt.com
  • chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"
    - "chatgpt.com"

See Network Configuration for more information.

Generated by Changeset Generator for issue #28339 ·



✨ PR Review Safe Output Test - Run 24913976844

💥 [THE END] — Illustrated by Smoke Claude · ● 178K ·

The `GH_AW_BIN=$(which gh-aw 2>/dev/null || find ...)` pattern fails under
`bash -e` because `which` exits with 1 when the binary is not on PATH,
potentially aborting the script before the `find` fallback runs. Also,
`find ... | head -1` with `set -o pipefail` can fail due to broken pipe.

Replace the single-line compound command with explicit sequential steps
using `|| true` to prevent errexit from aborting on failure:

  GH_AW_BIN=\"\"
  GH_AW_BIN=$(which gh-aw 2>/dev/null) || true
  if [ -z \"$GH_AW_BIN\" ]; then
    GH_AW_BIN=$(find \"${HOME}/.local/share/gh/extensions/gh-aw\" ...) || true
  fi

Changes:
- pkg/workflow/mcp_setup_generator.go: Fix compiled lock file generation
- .github/workflows/shared/mcp/gh-aw.md: Fix shared MCP component
- pkg/workflow/testdata/.../smoke-copilot.golden: Update golden file
- .github/workflows/*.lock.yml: Recompiled with updated logic

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/a3614c93-5459-43c4-b62e-144ddc1f9a2f

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Hey @Copilot 👋 — thanks for tackling the binary copy logic failure in pkg/workflow/mcp_setup_generator.go! Making shell scripts safe under bash -e (errexit) is an important reliability fix and a good catch.

A few things to address before this is ready for review:

  • Complete the WIP checklist — the PR body has three unchecked tasks (Fix binary copy logic, make recompile, make agent-finish). The diff is currently empty, so the actual code changes haven't landed yet.
  • Add a description — the body only contains a task checklist. A brief summary of what the logic failure is, why it breaks under errexit, and how the fix addresses it would help reviewers understand the intent.
  • Add or update tests — once the fix is in place, a test covering the corrected binary copy behaviour would confirm the fix holds.

If you'd like a hand finishing this up, here's a ready-to-use agent prompt:

In pkg/workflow/mcp_setup_generator.go, fix the binary copy logic so it is safe under bash -e (errexit).
Specifically:
1. Identify the copy operation that fails when the source binary does not exist or copy returns a non-zero exit code under errexit.
2. Rewrite the logic to guard the copy with an existence check or use a conditional that does not trigger errexit on an expected non-fatal condition.
3. Run `make recompile` to regenerate any lock files.
4. Run `make agent-finish` to validate all checks pass (build, test, lint, fmt, recompile).
5. Update the PR body with a plain-English description of the root cause and the fix applied.

Generated by Contribution Check · ● 2.2M ·

Copilot AI changed the title [WIP] Fix binary copy logic failure in compiled lock files Fix GH_AW_BIN detection failure under bash -e/pipefail Apr 24, 2026
Copilot AI requested a review from pelikhan April 24, 2026 21:18
@pelikhan pelikhan marked this pull request as ready for review April 24, 2026 21:22
Copilot AI review requested due to automatic review settings April 24, 2026 21:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes gh-aw binary detection in generated workflow steps so jobs don’t fail under GitHub Actions’ default bash -e + pipefail behavior when which returns non-zero or when find | head triggers a broken pipe.

Changes:

  • Updates the MCP setup generator to emit multi-line, || true-guarded gh-aw binary detection logic.
  • Applies the same detection logic to the shared shared/mcp/gh-aw.md component.
  • Recompiles golden/lock workflow artifacts to reflect the new generated script.
Show a summary per file
File Description
pkg/workflow/mcp_setup_generator.go Updates code generation for the gh-aw install step to avoid errexit/pipefail aborts during binary detection.
.github/workflows/shared/mcp/gh-aw.md Updates the shared workflow component with the same safer binary detection logic.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/smoke-copilot.golden Updates golden fixture output to match the new generated bash snippet.
.github/workflows/workflow-normalizer.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/weekly-blog-post-writer.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/static-analysis-report.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/smoke-copilot.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/smoke-copilot-arm.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/smoke-claude.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/security-review.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/safe-output-health.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/q.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/python-data-charts.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/prompt-clustering-analysis.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/metrics-collector.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/mcp-inspector.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/example-workflow-analyzer.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/dev-hawk.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/deep-report.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/daily-safe-output-optimizer.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/daily-rendering-scripts-verifier.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/daily-observability-report.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet (plus regenerated heredoc delimiters).
.github/workflows/daily-integrity-analysis.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/daily-firewall-report.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/daily-cli-tools-tester.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/copilot-token-audit.lock.yml Recompiled lock workflow (string run: form) with updated gh-aw binary detection snippet.
.github/workflows/cloclo.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/aw-failure-investigator.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/audit-workflows.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/api-consumption-report.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/agentic-optimization-kit.lock.yml Recompiled lock workflow (string run: form) with updated gh-aw binary detection snippet.
.github/workflows/agentic-observability-kit.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/agent-persona-explorer.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.
.github/workflows/agent-performance-analyzer.lock.yml Recompiled lock workflow with updated gh-aw binary detection snippet.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 34/34 changed files
  • Comments generated: 2

Comment on lines +205 to +209
yaml.WriteString(" GH_AW_BIN=\"\"\n")
yaml.WriteString(" GH_AW_BIN=$(which gh-aw 2>/dev/null) || true\n")
yaml.WriteString(" if [ -z \"$GH_AW_BIN\" ]; then\n")
yaml.WriteString(" GH_AW_BIN=$(find \"${HOME}/.local/share/gh/extensions/gh-aw\" -name 'gh-aw' -type f 2>/dev/null | head -1) || true\n")
yaml.WriteString(" fi\n")
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

GH_AW_BIN detection still relies on which, which is not guaranteed to be available in minimal runner/container images. In other parts of the generated workflows you already use which ... || command -v ..., so consider switching this to command -v gh-aw (or which ... || command -v ...) to make detection work even when which is missing.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/shared/mcp/gh-aw.md Outdated
mkdir -p "${RUNNER_TEMP}/gh-aw"
GH_AW_BIN=$(which gh-aw 2>/dev/null || find ~/.local/share/gh/extensions/gh-aw -name 'gh-aw' -type f 2>/dev/null | head -1)
GH_AW_BIN=""
GH_AW_BIN=$(which gh-aw 2>/dev/null) || true
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

This step uses which gh-aw to detect the binary. which is not always installed (especially in minimal/container environments), so the detection can still fail even if gh-aw is on $PATH. Prefer command -v gh-aw (or which ... || command -v ...) to make this more robust.

Suggested change
GH_AW_BIN=$(which gh-aw 2>/dev/null) || true
GH_AW_BIN=$(command -v gh-aw 2>/dev/null) || true

Copilot uses AI. Check for mistakes.
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.

The smoke test agent agrees — command -v is the right choice here over which. This is now addressed in the PR. 🤖✅

📰 BREAKING: Report filed by Smoke Copilot · ● 726.3K

@pelikhan
Copy link
Copy Markdown
Collaborator

Review all comments, merge main, and recompile. @copilot.

Copilot AI and others added 2 commits April 24, 2026 21:44
…py-logic-failure

# Conflicts:
#	.github/workflows/daily-observability-report.lock.yml

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
which is not guaranteed to be available in all environments; command -v
is a POSIX built-in that works even in minimal containers. Also merge main
and recompile all lock files.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7359daa4-8762-402c-90de-1185310c3f6b

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 24, 2026

Review all comments, merge main, and recompile. @copilot.

Done in a1cffe3: switched which gh-aw to command -v gh-aw (POSIX built-in, works in minimal environments), merged main, and recompiled all 201 lock files.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw m1YuW_Zcobpl (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw -I/z9U4yuXOJa8cJ-C (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .default_branch (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

⚠️ Smoke Crush failed. Crush encountered unexpected challenges...

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

⚠️ Smoke Gemini failed. Gemini encountered unexpected challenges...

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

🚀 Smoke OpenCode MISSION COMPLETE! OpenCode delivered. 🔥

@github-actions
Copy link
Copy Markdown
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions github-actions Bot removed the smoke label Apr 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.53.0
jq 1.7
yq 4.52.5
curl 8.5.0
gh 2.89.0
node 20.20.2
python3 3.12.3
go 1.24.13
java 10.0.201
dotnet NOT FOUND

Result: 11/12 tools available ⚠️

Overall Status: FAILdotnet (.NET runtime) is not available in this container.

🔧 Tool validation by Agent Container Smoke Test · ● 118.3K ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test

  • PRs: #28353 fix(design-decision-gate): add git ls-remote permission, raise turn limit to 20, add MCP fallback; #28341 fix: add regression tests for protected-files object form compilation
  • GitHub MCP ✅ Serena ✅ Playwright ✅ File write ✅ Bash cat ✅ Build ✅
  • Web-fetch ❌
  • Comment memory ❌
  • Overall: FAIL

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • ab.chatgpt.com
  • chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"
    - "chatgpt.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results (run §24913976862)\n\n@pelikhan @Copilot\n\n| Test | Status |\n|------|--------|\n| GitHub MCP | ✅ |\n| MCP Scripts GH CLI | ✅ |\n| Serena CLI | ✅ |\n| Playwright | ✅ |\n| Web Fetch | ❌ (tool unavailable) |\n| File Write/Read | ✅ |\n| Discussion Interaction | ✅ |\n| Build gh-aw | ✅ |\n| Upload Artifact | ✅ |\n| Discussion Creation | ✅ |\n| Workflow Dispatch | ✅ |\n| PR Review | ✅ |\n| Comment Memory | ❌ (no files) |\n\nOverall: ⚠️ PARTIAL PASS (12/14)

📰 BREAKING: Report filed by Smoke Copilot · ● 726.3K ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Smoke test review of PR #28339. The binary detection fix is correct and addresses the bash -e/pipefail reliability issue. Two inline comments left on specific lines. Overall the approach is solid.

📰 BREAKING: Report filed by Smoke Copilot · ● 726.3K

@github-actions
Copy link
Copy Markdown
Contributor

Commit pushed: 7cb2584

Generated by Changeset Generator

@github-actions
Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Run 24913976844 — Claude Engine

Core tests #1–12: ✅✅✅✅✅✅✅✅✅ ❌ ✅✅
PR review tests #13–19: ✅✅✅✅⚠️✅✅⚠️

Overall: PARTIAL (Test #10 Agentic Workflows MCP failed; #16/#19 skipped)

💥 [THE END] — Illustrated by Smoke Claude · ● 178K ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal! Run 24913976844 — Claude engine validation complete.

💥 [THE END] — Illustrated by Smoke Claude · ● 178K

GH_AW_BIN=$(which gh-aw 2>/dev/null || find ~/.local/share/gh/extensions/gh-aw -name 'gh-aw' -type f 2>/dev/null | head -1)
GH_AW_BIN=""
GH_AW_BIN=$(command -v gh-aw 2>/dev/null) || true
if [ -z "$GH_AW_BIN" ]; then
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.

🔍 Smoke test review comment #1 — The binary detection fallback using command -v gh-aw followed by a find fallback looks correct and robust. Good use of POSIX-compatible command -v over which. Run 24913976844.

GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
name: Install gh-aw extension
run: "# Install gh-aw if not already available\nif ! gh aw --version >/dev/null 2>&1; then\n echo \"Installing gh-aw extension...\"\n curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash\nfi\ngh aw --version\n# Copy the gh-aw binary to ${RUNNER_TEMP}/gh-aw for MCP server containerization\nmkdir -p \"${RUNNER_TEMP}/gh-aw\"\nGH_AW_BIN=$(which gh-aw 2>/dev/null || find ~/.local/share/gh/extensions/gh-aw -name 'gh-aw' -type f 2>/dev/null | head -1)\nif [ -n \"$GH_AW_BIN\" ] && [ -f \"$GH_AW_BIN\" ]; then\n cp \"$GH_AW_BIN\" \"${RUNNER_TEMP}/gh-aw/gh-aw\"\n chmod +x \"${RUNNER_TEMP}/gh-aw/gh-aw\"\n echo \"Copied gh-aw binary to ${RUNNER_TEMP}/gh-aw/gh-aw\"\nelse\n echo \"::error::Failed to find gh-aw binary for MCP server\"\n exit 1\nfi\n"
run: "# Install gh-aw if not already available\nif ! gh aw --version >/dev/null 2>&1; then\n echo \"Installing gh-aw extension...\"\n curl -fsSL https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/install-gh-aw.sh | bash\nfi\ngh aw --version\n# Copy the gh-aw binary to ${RUNNER_TEMP}/gh-aw for MCP server containerization\nmkdir -p \"${RUNNER_TEMP}/gh-aw\"\nGH_AW_BIN=\"\"\nGH_AW_BIN=$(command -v gh-aw 2>/dev/null) || true\nif [ -z \"$GH_AW_BIN\" ]; then\n GH_AW_BIN=$(find \"${HOME}/.local/share/gh/extensions/gh-aw\" -name 'gh-aw' -type f 2>/dev/null | head -1) || true\nfi\nif [ -n \"$GH_AW_BIN\" ] && [ -f \"$GH_AW_BIN\" ]; then\n cp \"$GH_AW_BIN\" \"${RUNNER_TEMP}/gh-aw/gh-aw\"\n chmod +x \"${RUNNER_TEMP}/gh-aw/gh-aw\"\n echo \"Copied gh-aw binary to ${RUNNER_TEMP}/gh-aw/gh-aw\"\nelse\n echo \"::error::Failed to find gh-aw binary for MCP server\"\n exit 1\nfi\n"
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.

🔍 Smoke test review comment #2 — The single-line run script has been correctly updated to initialize GH_AW_BIN="" before attempting detection, preventing potential issues with unbound variables in strict shell environments. Run 24913976844.

@pelikhan pelikhan merged commit 87347e9 into main Apr 24, 2026
@pelikhan pelikhan deleted the copilot/fix-binary-copy-logic-failure branch April 24, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binary copy logic fails with bash -e: 'Failed to find gh-aw binary for MCP server'

3 participants