Skip to content

fix: log stderr as well#8

Merged
gusfcarvalho merged 1 commit intomainfrom
gc-fix-log-stderr
Apr 14, 2026
Merged

fix: log stderr as well#8
gusfcarvalho merged 1 commit intomainfrom
gc-fix-log-stderr

Conversation

@gusfcarvalho
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Copilot AI review requested due to automatic review settings April 14, 2026 12:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Cloud Custodian execution flow to include captured stderr output in the structured error list when command execution fails, improving error visibility during failures.

Changes:

  • Append result.Stderr to result.Errors when cmd.Run() returns an error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.go
Comment on lines 261 to +266
if err != nil {
result.Err = fmt.Errorf("custodian execution failed: %w", err)
result.Errors = append(result.Errors, result.Err.Error())
if result.Stderr != "" {
result.Errors = append(result.Errors, result.Stderr)
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces new behavior (stderr is added to result.Errors when cmd.Run() fails), but there is no test exercising the failure path with non-empty stderr to ensure it’s included (and to lock in expectations around formatting/truncation). Please add a unit test in the existing TestCommandCustodianExecutor suite for a script that exits non-zero and writes to stderr.

Copilot uses AI. Check for mistakes.
Comment thread main.go
Comment on lines +264 to +266
if result.Stderr != "" {
result.Errors = append(result.Errors, result.Stderr)
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appending raw result.Stderr into result.Errors will duplicate stderr in the final payload (Execution.Stderr is already populated) and will also cause the warning log at the end of Execute to emit the full stderr content under the errors field. This can significantly bloat logs/payloads and may include newlines or sensitive data. Consider keeping Errors for discrete error messages and instead logging stderr separately (ideally trimmed and length-capped), or only adding a summarized/truncated stderr entry to Errors.

Copilot uses AI. Check for mistakes.
@gusfcarvalho gusfcarvalho merged commit ec1aee7 into main Apr 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants