Conversation
…e for pre-activation failures
- Fix contradictory "failed with 0 error(s)" message: when ErrorCount==0 and no
errors are available, emit "failed before agent activation — no error logs were
available to analyze" instead
- Fix wrong workflow_name: when the GitHub API returns the file path as the run
name, resolve the actual display name by reading the local workflow YAML file
first, then falling back to the GitHub API /actions/workflows/{filename}
- Improve 404 detection in fetchWorkflowRunMetadata to handle more error variants
(adds "not found", "Could not resolve", err.Error() checks)
- Add tests: pre-activation failure message, extractWorkflowNameFromYAML (7 cases),
and resolveWorkflowDisplayNameFromLocalFile
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes two user-facing issues in the audit command when a workflow run fails before agent activation: an incorrect “failed with 0 error(s)” finding and workflow names showing as workflow file paths instead of display names.
Changes:
- Update failure finding text to explicitly indicate pre-activation failures when no logs/errors are available.
- Resolve workflow display name when GitHub returns a workflow file path as the run name (local YAML read first, then GitHub API fallback).
- Improve 404 detection to emit a clearer “workflow run N not found” error across more
ghCLI variants.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/cli/audit.go | Improves run-not-found messaging and adds workflow display-name resolution logic. |
| pkg/cli/audit_report_analysis.go | Adjusts failure finding description to avoid contradictory “0 error(s)” message when no logs exist. |
| pkg/cli/audit_report_test.go | Adds coverage for the new pre-activation failure finding message. |
| pkg/cli/audit_test.go | Adds unit tests for YAML workflow name extraction and local-file display-name resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
pkg/cli/audit.go
Outdated
| // Try local file first (works when audit is run from inside a cloned repository). | ||
| if content, err := os.ReadFile(workflowPath); err == nil { | ||
| if name := extractWorkflowNameFromYAML(string(content)); name != "" { | ||
| return name | ||
| } | ||
| } |
pkg/cli/audit.go
Outdated
| // extractWorkflowNameFromYAML scans the top-level YAML content for a 'name:' key and | ||
| // returns its value. Only the first occurrence at the root level is considered. | ||
| // This intentionally avoids importing a full YAML parser to keep the dependency | ||
| // footprint minimal. | ||
| func extractWorkflowNameFromYAML(content string) string { | ||
| for line := range strings.SplitSeq(content, "\n") { | ||
| trimmed := strings.TrimSpace(line) | ||
| // Skip blank lines and YAML comments. | ||
| if trimmed == "" || strings.HasPrefix(trimmed, "#") { | ||
| continue | ||
| } | ||
| // A top-level key starts at column 0 (no leading whitespace). | ||
| if !strings.HasPrefix(line, " ") && !strings.HasPrefix(line, "\t") { | ||
| if after, ok := strings.CutPrefix(trimmed, "name:"); ok { | ||
| name := strings.TrimSpace(after) | ||
| // Strip optional surrounding quotes (single or double). | ||
| name = strings.Trim(name, "\"'") | ||
| return name |
|
@copilot review comments. Use helpers to resolve workflow file from workflow name |
… resolution Address review feedback: - resolveWorkflowDisplayName now uses findGitRoot() so the repo-relative workflowPath is resolved to an absolute path, working from any subdirectory - extractWorkflowNameFromYAML replaced manual string scanning with goccy/go-yaml struct unmarshaling, correctly handling inline comments and all YAML scalar forms - Tests updated to use []byte signature and add inline-comment case Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in ab3397d. The changes address both reviewer suggestions:
|
For runs that fail before agent activation (cancelled, infrastructure-level failures, no downloadable artifacts), the
audittool produced two user-facing bugs: a logically contradictory"Workflow failed with 0 error(s)"finding, andworkflow_nameshowing the file path (.github/workflows/daily-cli-tools-tester.lock.yml) instead of the display name (Daily CLI Tools Exploratory Tester).Changes
Fix 1 — Contradictory failure message (
audit_report_analysis.go)When
ErrorCount == 0and no error objects are available (i.e. no logs to analyze), the description now reads:The existing
"failed with N error(s)"format is kept when error data is present.Fix 2 — Wrong
workflow_namein overview (audit.go)The GitHub REST API sporadically returns the workflow file path as
.namefor quickly-cancelled runs. AddedresolveWorkflowDisplayName, called infetchWorkflowRunMetadatawhenWorkflowNamestarts with.github/:findGitRoot()to resolve the repo-relative workflow path to an absolute path, then reads and parses the local YAML file usinggoccy/go-yaml— works correctly from any subdirectory within the repository.GET /actions/workflows/{filename}for remote-repo (--repo) usage.A companion
extractWorkflowNameFromYAMLhelper unmarshals the YAML into a typed struct usinggoccy/go-yaml, correctly handling inline comments, quoted scalars, and all valid YAML forms.Fix 3 — Non-existent run ID error message (
audit.go)Broadened the 404 detection heuristics to cover more
ghCLI version variants: adds"not found","Could not resolve", anderr.Error()checks alongside the existing"Not Found"/"404"string matches, so users get"workflow run N not found"instead of the opaque"failed to fetch run metadata".Tests added
TestGenerateFindings/failed_workflow_with_zero_errors_and_no_error_details_uses_pre-activation_message— verifies the new message and that"0 error(s)"is never emitted for zero-error failuresTestExtractWorkflowNameFromYAML— 8 cases (quoted names, inline comments, indented keys, empty content)TestResolveWorkflowDisplayNameFromLocalFile— validates YAML name extraction directly💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.