Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/patch-log-gh-workflow-errors.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ COPY ${BINARY} /usr/local/bin/gh-aw
# Ensure the binary is executable
RUN chmod +x /usr/local/bin/gh-aw

# Configure git to trust all directories to avoid "dubious ownership" errors
# This is necessary when the container runs with mounted volumes owned by different users
RUN git config --global --add safe.directory '*'

# Set working directory for users
WORKDIR /workspace

Expand Down
30 changes: 29 additions & 1 deletion pkg/cli/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -84,6 +85,21 @@ func fetchGitHubWorkflows(repoOverride string, verbose bool) (map[string]*GitHub
if !verbose {
spinner.Stop()
}

// Extract detailed error information including exit code and stderr
var exitCode int
var stderr string
if exitErr, ok := err.(*exec.ExitError); ok {
exitCode = exitErr.ExitCode()
stderr = string(exitErr.Stderr)
workflowsLog.Printf("gh workflow list command failed with exit code %d. Command: gh %v", exitCode, args)
workflowsLog.Printf("stderr output: %s", stderr)

return nil, fmt.Errorf("failed to execute gh workflow list command (exit code %d): %w. stderr: %s", exitCode, err, stderr)
}

// If not an ExitError, log what we can
workflowsLog.Printf("gh workflow list command failed with error (not ExitError): %v. Command: gh %v", err, args)
return nil, fmt.Errorf("failed to execute gh workflow list command: %w", err)
}

Expand Down Expand Up @@ -195,7 +211,19 @@ func restoreWorkflowState(workflowIdOrName string, workflowID int64, repoOverrid
}
cmd := workflow.ExecGH(args...)
if err := cmd.Run(); err != nil {
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to restore workflow '%s' to disabled state: %v", workflowIdOrName, err)))
// Extract detailed error information including exit code and stderr
var exitCode int
var stderr string
if exitErr, ok := err.(*exec.ExitError); ok {
exitCode = exitErr.ExitCode()
stderr = string(exitErr.Stderr)
workflowsLog.Printf("gh workflow disable command failed with exit code %d. Command: gh %v", exitCode, args)
workflowsLog.Printf("stderr output: %s", stderr)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to restore workflow '%s' to disabled state (exit code %d): %v. stderr: %s", workflowIdOrName, exitCode, err, stderr)))
} else {
workflowsLog.Printf("gh workflow disable command failed with error (not ExitError): %v. Command: gh %v", err, args)
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to restore workflow '%s' to disabled state: %v", workflowIdOrName, err)))
}
} else {
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("Restored workflow to disabled state: %s", workflowIdOrName)))
}
Expand Down
Loading