Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

Error and warning messages in verbose mode used plain fmt.Printf instead of console formatting, resulting in inconsistent styling and incorrect stdout routing.

Changes

pkg/cli/run_workflow_tracking.go

  • Added os import
  • Converted 3 verbose messages: 2 errors, 1 warning

pkg/cli/file_tracker.go

  • Added console import
  • Converted 1 verbose warning message

Example

// Before
fmt.Printf("Attempt %d/%d failed: %v\n", attempt+1, maxRetries, err)
fmt.Printf("Warning: Could not parse creation time '%s': %v\n", createdAt, err)

// After
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Attempt %d/%d failed: %v", attempt+1, maxRetries, err)))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Could not parse creation time '%s': %v", createdAt, err)))

Console formatting provides consistent error styling (✗/⚠ icons), proper stderr routing, and TTY-aware ANSI code handling.

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Standardize error messages to use console.FormatErrorMessage()</issue_title>
<issue_description>## Objective

Convert all user-facing error messages to use console.FormatErrorMessage() and ensure they go to stderr for consistency.

Context

From discussion #11611: Multiple CLI files use direct fmt.Printf for error messages instead of the standardized console formatting. This affects user experience and consistency.

Files with Issues: commands.go, git.go, file_tracker.go, run_workflow_tracking.go

Approach

  1. Audit each file for error message patterns:

    • Search for fmt.Printf with error-related text
    • Identify messages that should use console.FormatErrorMessage()
    • Ensure output goes to stderr
  2. Convert error messages:

    • Use fmt.Fprintln(os.Stderr, console.FormatErrorMessage(...))
    • Maintain clear, actionable error messages
    • Ensure proper error wrapping with %w
  3. Test changes:

    • Verify errors display correctly in terminal
    • Test non-TTY mode strips ANSI codes
    • Run existing tests to ensure no regressions

Files to Modify

  • Update: pkg/cli/commands.go
  • Update: pkg/cli/git.go
  • Update: pkg/cli/file_tracker.go
  • Update: pkg/cli/run_workflow_tracking.go

Pattern to Follow

// ❌ WRONG - Direct fmt.Printf without console formatting:
fmt.Printf("Error: Failed to process workflow: %v\n", err)

// ✅ CORRECT - Console formatted error to stderr:
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))

// ✅ CORRECT - With context:
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Failed to process workflow: %v", err)))

Acceptance Criteria

  • All error messages in commands.go use console formatting
  • All error messages in git.go use console formatting
  • All error messages in file_tracker.go use console formatting
  • All error messages in run_workflow_tracking.go use console formatting
  • All error output goes to stderr
  • Existing tests pass
  • Code passes make fmt and make lint
  • make agent-finish completes successfully

Priority

Phase 2: Standardize Error Messages (4-6 hours estimated)

AI generated by Plan Command for discussion #11611

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 24, 2026 11:59
…ssage()

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Standardize user-facing error messages to use console.FormatErrorMessage() Standardize error messages to use console formatting with stderr Jan 24, 2026
Copilot AI requested a review from pelikhan January 24, 2026 12:09
@pelikhan pelikhan marked this pull request as ready for review January 24, 2026 12:10
@pelikhan pelikhan merged commit ee00f8b into main Jan 24, 2026
@pelikhan pelikhan deleted the copilot/standardize-error-messages branch January 24, 2026 12:10
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.

[plan] Standardize error messages to use console.FormatErrorMessage()

2 participants