Skip to content

Commit 35001cf

Browse files
authored
fix(audit): surface activation job errors when no agent artifacts were uploaded (#19678)
1 parent d5160e8 commit 35001cf

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

.github/workflows/constraint-solving-potd.lock.yml

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/setup-cli/install.sh

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cli/logs_download.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,22 @@ func downloadRunArtifacts(runID int64, outputDir string, verbose bool, owner, re
623623

624624
// Check if it's because there are no artifacts
625625
if strings.Contains(string(output), "no valid artifacts") || strings.Contains(string(output), "not found") {
626-
// Clean up empty directory
627-
if err := os.RemoveAll(outputDir); err != nil && verbose {
628-
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to clean up empty directory %s: %v", outputDir, err)))
629-
}
630626
if verbose {
631627
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("No artifacts found for run %d (gh run download reported none)", runID)))
632628
}
629+
// Even with no artifacts, attempt to download workflow run logs so that
630+
// pre-agent step failures (e.g., activation job errors) can be diagnosed.
631+
if logErr := downloadWorkflowRunLogs(runID, outputDir, verbose, owner, repo, hostname); logErr != nil {
632+
if verbose {
633+
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to download workflow run logs: %v", logErr)))
634+
}
635+
// Clean up empty directory only if logs download also produced nothing
636+
if fileutil.IsDirEmpty(outputDir) {
637+
if removeErr := os.RemoveAll(outputDir); removeErr != nil && verbose {
638+
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to clean up empty directory %s: %v", outputDir, removeErr)))
639+
}
640+
}
641+
}
633642
return ErrNoArtifacts
634643
}
635644
// Check for authentication errors

0 commit comments

Comments
 (0)