Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

MCP logs tool failures returned only "failed to download workflow logs" with no diagnostic context, making debugging impossible without access to the runner environment.

Changes

Pre-execution logging

  • Logs command args, flags, and timeout before execution via mcpLog.Printf

Post-failure logging

  • Captures stdout/stderr lengths, exit code, and error on failure
  • Switches from CombinedOutput() to Output() for separate stdout/stderr handling

Enhanced error response

  • MCP error data now includes: command string, exit code, stdout, stderr, timeout, workflow name
  • Error message includes actual error text: "failed to download workflow logs: exit status 1" vs "failed to download workflow logs"
// Before
cmd := execCmd(ctx, cmdArgs...)
output, err := cmd.CombinedOutput()
if err != nil {
    return nil, nil, &jsonrpc.Error{
        Code:    jsonrpc.CodeInternalError,
        Message: "failed to download workflow logs",
        Data:    mcpErrorData(map[string]any{"error": err.Error(), "output": string(output)}),
    }
}

// After  
cmd := execCmd(ctx, cmdArgs...)
stdout, err := cmd.Output()
outputStr := string(stdout)

if err != nil {
    var stderr string
    var exitCode int
    if exitErr, ok := err.(*exec.ExitError); ok {
        stderr = string(exitErr.Stderr)
        exitCode = exitErr.ExitCode()
    }
    
    mcpLog.Printf("Logs command exited with error: %v (stdout: %d, stderr: %d, exit_code: %d)", 
        err, len(outputStr), len(stderr), exitCode)
    
    errorData := map[string]any{
        "error": err.Error(), "command": strings.Join(cmdArgs, " "),
        "exit_code": exitCode, "stdout": outputStr, "stderr": stderr,
        "timeout": timeoutValue, "workflow": args.WorkflowName,
    }
    
    return nil, nil, &jsonrpc.Error{
        Code: jsonrpc.CodeInternalError,
        Message: fmt.Sprintf("failed to download workflow logs: %s", err.Error()),
        Data: mcpErrorData(errorData),
    }
}

Pattern matches existing compile tool error handling in same file.

Original prompt

Reference: https://github.com/github/gh-aw/actions/runs/21631437663/job/62344969996

Debug why the agentic workflows MCP failed to download the logs.

Find the code in MCP-server that generates this message and provide better logging.

Custom agent used: agentic-workflows
GitHub Agentic Workflows (gh-aw) - Create, debug, and upgrade AI-powered workflows with intelligent prompt routing


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

Copilot AI and others added 2 commits February 3, 2026 13:26
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…hs and exit code

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan added the smoke label Feb 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 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 3, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.50.1
curl 8.5.0
gh 2.86.0
node 24.13.0
python3 3.13.11
go 1.24.12
java not found
dotnet not found

Result: 10/12 tools available ⚠️

Missing Tools:

  • java - command not found
  • dotnet - command not found

All essential development tools (shell, git, JSON/YAML processing, HTTP, GitHub CLI, and core runtimes like Node, Python, Go) are available. Java and .NET runtimes are not installed in this container.

AI generated by Agent Container Smoke Test

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

PR titles: Remove shared gh-aw import and inline MCP config in agentic workflows; Update Codex to 0.94.0 and Sandbox Runtime to 0.0.34
GitHub MCP ✅; SafeInputs GH ✅; Serena ✅
Playwright ❌ (tool missing); Tavily ✅; File write ✅
Bash cat ✅; Discussion ✅; Build ❌ (make build timeout)
Overall: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Smoke Test Results - Run 21632095567

PRs Tested:

Test Status
GitHub MCP
Safe Inputs GH CLI
Serena MCP
File Writing
Bash Tool
Discussion Interaction
Build gh-aw
Workflow Dispatch
Playwright

Overall Status: PASS (Playwright pending)

cc @pelikhan @Copilot

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

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

Copilot AI changed the title [WIP] Debug MCP workflows log download failure Add diagnostic logging to MCP logs tool error path Feb 3, 2026
Copilot AI requested a review from pelikhan February 3, 2026 13:34
@pelikhan pelikhan marked this pull request as ready for review February 3, 2026 13:37
Copilot AI review requested due to automatic review settings February 3, 2026 13:37
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.

Pull request overview

Adds diagnostic logging and richer error reporting for the MCP logs tool so failures include actionable execution context (command, exit info, stdout/stderr) instead of a generic message.

Changes:

  • Logs the logs tool command parameters prior to execution.
  • Switches from CombinedOutput() to Output() to keep JSON stdout separate from stderr.
  • Enriches the JSON-RPC error message/data with command details, exit code, stdout, stderr, timeout, and workflow name.

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

Comment on lines +494 to +496
// Log the command being executed for debugging
mcpLog.Printf("Executing logs tool: workflow=%s, count=%d, firewall=%v, no_firewall=%v, timeout=%d, command_args=%v",
args.WorkflowName, args.Count, args.Firewall, args.NoFirewall, timeoutValue, cmdArgs)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The pre-exec log prints count=%d using args.Count, but when the MCP client omits count this will log 0 even though the underlying CLI has its own default (currently gh aw logs --count defaults to 10 in pkg/cli/logs_command.go:212). This can be misleading, and it also means the MCP-described default (schema sets 100) is not actually enforced by the server. Consider computing an explicit effectiveCount (apply the MCP default when args.Count==0) and always passing -c effectiveCount, and log that effective value.

Copilot uses AI. Check for mistakes.
Comment on lines +511 to +516
var stderr string
var exitCode int
if exitErr, ok := err.(*exec.ExitError); ok {
stderr = string(exitErr.Stderr)
exitCode = exitErr.ExitCode()
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

When cmd.Output() fails for reasons other than *exec.ExitError (e.g., context deadline exceeded / process killed), exitCode remains 0, which can incorrectly suggest success in both logs and jsonrpc error data. Consider initializing exitCode to a sentinel (e.g., -1) or omitting the field unless err is an *exec.ExitError.

Copilot uses AI. Check for mistakes.
Comment on lines +521 to +530
// Build detailed error data
errorData := map[string]any{
"error": err.Error(),
"command": strings.Join(cmdArgs, " "),
"exit_code": exitCode,
"stdout": outputStr,
"stderr": stderr,
"timeout": timeoutValue,
"workflow": args.WorkflowName,
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

errorData includes full stdout and stderr strings. These streams can be very large (or contain sensitive content), which can bloat the JSON-RPC error payload and potentially leak data to clients/logs. Consider truncating stdout/stderr to a bounded size (and/or providing separate stdout_len/stderr_len fields), and optionally sanitizing before returning them in Data.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit a13e6be into main Feb 3, 2026
191 checks passed
@pelikhan pelikhan deleted the copilot/debug-workflows-mcp-logs branch February 3, 2026 13:41
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