@@ -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