Skip to content

Capture exit codes and stderr when gh CLI commands fail, fix Docker git ownership#14156

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-gh-workflows-list-failure
Feb 6, 2026
Merged

Capture exit codes and stderr when gh CLI commands fail, fix Docker git ownership#14156
pelikhan merged 5 commits intomainfrom
copilot/fix-gh-workflows-list-failure

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

When gh workflow list failed in the status command, error logs contained only wrapped errors without exit codes, stderr output, or the executed command. Additionally, the Docker container was experiencing "dubious ownership in repository" errors when running with mounted volumes.

Changes

  • Enhanced fetchGitHubWorkflows error handling

    • Extract exit code from exec.ExitError
    • Capture and log stderr output
    • Log full command with arguments via workflowsLog
  • Applied same pattern to restoreWorkflowState

    • Consistent error diagnostics for gh workflow disable failures
  • Fixed Docker container git ownership issue

    • Added git config --global --add safe.directory '*' to Dockerfile
    • Prevents "fatal: detected dubious ownership in repository" errors
    • Necessary when container runs with mounted volumes owned by different users (e.g., GitHub Actions)

Example

Before:

if err != nil {
    return nil, fmt.Errorf("failed to execute gh workflow list command: %w", err)
}

After:

if err != nil {
    var exitCode int
    var stderr string
    if exitErr, ok := err.(*exec.ExitError); ok {
        exitCode = exitErr.ExitCode()
        stderr = string(exitErr.Stderr)
        workflowsLog.Printf("gh workflow list command failed with exit code %d. Command: gh %v", exitCode, args)
        workflowsLog.Printf("stderr output: %s", stderr)
        return nil, fmt.Errorf("failed to execute gh workflow list command (exit code %d): %w. stderr: %s", exitCode, err, stderr)
    }
    workflowsLog.Printf("gh workflow list command failed with error (not ExitError): %v. Command: gh %v", err, args)
    return nil, fmt.Errorf("failed to execute gh workflow list command: %w", err)
}

Pattern matches existing implementation in fetchLatestRunsByRef for consistency.

Original prompt

Reference: https://github.com/github/gh-aw/actions/runs/21754229152/job/62759997935#step:44:1

It seems that the call to gh workflows list in the status command is failing. Make that maximum logging is collected when a call to "gh" fails.

See agentic-workflows.log in the artifacts of the run.

Check that the token passed to the MCP server is secrets.GITHUB_TOKEN and that it has enough permissions


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Changeset

  • Type: patch
  • Description: Log exit codes and stderr for failing gh workflow list/disable commands and configure the Docker image to trust every directory so mounted volumes do not trigger dubious ownership errors.

Generated by Changeset Generator

- Extract exit code from ExitError when gh workflow list fails
- Capture and log stderr output for debugging
- Log the full command that was executed
- Apply same pattern to gh workflow disable command in restoreWorkflowState
- Add os/exec import for ExitError type
- Match logging pattern used in fetchLatestRunsByRef for consistency

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve logging on gh command failures Capture exit codes and stderr when gh CLI commands fail Feb 6, 2026
Copilot AI requested a review from pelikhan February 6, 2026 15:01
@pelikhan pelikhan added the smoke label Feb 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Changeset Generator failed. Please review the logs for details.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.52.2
curl 8.5.0
gh 2.86.0
node 20.20.0
python3 3.12.3
go 1.24.12
java 21.0.10 (requires LD_LIBRARY_PATH)
dotnet execution error

Result: 11/12 tools available ⚠️

Notes:

  • Java: Works correctly but requires LD_LIBRARY_PATH to be set properly
  • Dotnet: Binary is present at /usr/share/dotnet/dotnet but fails with error: "cannot execute dotnet when renamed to bash" - this appears to be an environment configuration issue rather than a missing installation

AI generated by Agent Container Smoke Test

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Smoke Test Results ✅

PR #14156 - Capture exit codes and stderr when gh CLI commands fail
PR #14027 - chore: bump AWF to v0.13.9

  • ✅ GitHub MCP
  • ✅ Safe Inputs GH CLI
  • ✅ Serena MCP (6 symbols)
  • ✅ Playwright
  • ✅ File I/O
  • ✅ Bash Tools
  • ✅ Discussion Comment
  • ✅ Build gh-aw
  • ✅ Workflow Dispatch

Status: PASS | Run §21755113641

cc @pelikhan

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@pelikhan
Copy link
Contributor

pelikhan commented Feb 6, 2026

@copilot the gh workflow command failed with this message:

  [2026-02-06T15:04:39Z] [INFO] [backend] [stderr] cli:workflows stderr output: failed to run git: fatal: detected dubious ownership in repository at '/home/runner/work/gh-aw/gh-aw'

Fix Dockerfile configure to remove this issue.

Configure git to trust all directories in Dockerfile to prevent
"fatal: detected dubious ownership in repository" errors when
running the container with mounted volumes owned by different users.

This is necessary because the container runs as root but the mounted
workspace directory is owned by the host user (e.g., runner in GitHub Actions).

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

Copilot AI commented Feb 6, 2026

@copilot the gh workflow command failed with this message:

  [2026-02-06T15:04:39Z] [INFO] [backend] [stderr] cli:workflows stderr output: failed to run git: fatal: detected dubious ownership in ...

Fixed in commit 21cd16e. Added git config --global --add safe.directory '*' to the Dockerfile to trust all directories and prevent the "dubious ownership" error when the container runs with mounted volumes owned by different users.

Copilot AI changed the title Capture exit codes and stderr when gh CLI commands fail Capture exit codes and stderr when gh CLI commands fail, fix Docker git ownership Feb 6, 2026
@pelikhan pelikhan added the smoke label Feb 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Changeset Generator completed successfully!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Agent Container Tool Check - Smoke Test Results

Tool Status Version
bash 5.2.21(1)-release
sh available
git 2.52.0
jq 1.7
yq 4.52.2
curl 8.5.0
gh 2.86.0
node 20.20.0
python3 3.12.3
go 1.24.12
java unavailable
dotnet unavailable

Result: 10/12 tools available ❌

Missing Tools:

  • Java runtime is not accessible (expected at /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/)
  • .NET runtime is not accessible (expected at /usr/bin/dotnet)

Core development tools (bash, git, gh, node, python3, go) and essential utilities (jq, yq, curl) are all available and functional.

AI generated by Agent Container Smoke Test

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Smoke Test Results - Run 21755850804

PRs Reviewed:

Test Results:

  • ✅ GitHub MCP
  • ✅ Safe Inputs GH CLI
  • ⚠️ Serena MCP (0 symbols found)
  • ✅ Playwright
  • ✅ File Writing
  • ✅ Bash Tools
  • ✅ Discussion Interaction
  • ✅ Build gh-aw
  • ✅ Workflow Dispatch

Overall Status: ⚠️ PARTIAL PASS

@Copilot

AI generated by Smoke Copilot

@github-actions github-actions bot removed the smoke label Feb 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@pelikhan
Copy link
Contributor

pelikhan commented Feb 6, 2026

@copilot increase smoke-claude timeout to 15min

@pelikhan pelikhan marked this pull request as ready for review February 6, 2026 15:44
Copilot AI review requested due to automatic review settings February 6, 2026 15:44
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@pelikhan pelikhan merged commit dd559bb into main Feb 6, 2026
2 checks passed
@pelikhan pelikhan deleted the copilot/fix-gh-workflows-list-failure branch February 6, 2026 15:44
Copilot AI requested a review from pelikhan February 6, 2026 15:44
Copilot stopped work on behalf of pelikhan due to an error February 6, 2026 15:44
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.

2 participants