-
Notifications
You must be signed in to change notification settings - Fork 34
Add exit code and stderr logging for GitHub CLI command failures with intelligent error detection #8906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add an heuristic to show the "invalid field" error message instead of the incorrect auth message. See the run at https://github.com/githubnext/gh-aw/actions/runs/20695486080/job/59410164371#step:5:1 |
|
@copilot keep working |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added error detection heuristic in commit a23e7f0. The code now checks for invalid field errors (e.g., "invalid field", "unknown field", "field not found", "no such field") before checking for authentication errors. This ensures that when Details" instead of the misleading "GitHub CLI authentication required" message. |
|
@copilot fix gh run list invocation. path is not a valid field name. See log below: cli:logs_github_api gh run list command failed with exit code 1. Command: gh [run list --json databaseId,number,url,status,conclusion,workflowName,path,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 250] +57ms |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in commit 9f94566. Removed the invalid "path" field from the |
When
gh run listcommands fail, there was no logging of exit codes or error output, making debugging difficult even whenGH_TOKENwas set. Additionally, invalid JSON field errors were being incorrectly reported as authentication errors, and the command was using an invalid "path" field that doesn't exist in the GitHub API.Changes
pkg/cli/status_command.go: Extract and log exit code + stderr whengh run listfails infetchLatestRunsByRefpkg/cli/logs_github_api.go: Extract and log exit code + combined output whengh run listfails inlistWorkflowRunsWithPagination; removed invalid "path" field from JSON querypkg/cli/logs_test.go: Updated test expectations to match the corrected JSON field listBoth use
exec.ExitErrortype assertion to capture exit codes and output, logging via existing debug logger infrastructure (cli:status_command,cli:logs_github_api).Error Detection
The code now checks errors in priority order:
"invalid field","unknown field","field not found","no such field"patternsThis ensures users see accurate error messages like
"invalid field in JSON query"instead of misleading"GitHub CLI authentication required"messages when the actual problem is an invalid JSON field.JSON Query Fix
Removed the invalid "path" field from the
gh run list --jsonquery. The GitHub API only supports these fields:attempt,conclusion,createdAt,databaseId,displayTitle,event,headBranch,headSha,name,number,startedAt,status,updatedAt,url,workflowDatabaseId,workflowName.Usage
Enable debug logging to see enhanced error details:
DEBUG=cli:* gh aw logsExample output on invalid field error:
Example output on authentication error:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.