Skip to content

[deep-report] Add a lint rule to catch Format*Message (non-Stderr) output written to os.Stderr in pkg/cli #66976

Description

@github-actions

Description

pkg/console/console.go already provides dedicated stderr-safe formatter variants (FormatInfoMessageStderr, FormatSuccessMessageStderr, FormatErrorStderr, FormatTableHeaderStderr), but a live grep today found roughly 1,662 call sites across ~192 files in pkg/cli that still pipe the plain (stdout-TTY-aware) Format*Message helpers into fmt.Fprintln(os.Stderr, ...) / fmt.Fprintf(os.Stderr, ...) instead of the *Stderr variant. Because the plain formatters make color/TTY decisions based on os.Stdout, output written to stderr this way can render inconsistently depending on which stream is actually a terminal (e.g., piped stdout with a terminal stderr, or vice versa).

Expected Impact

Prevents new stdout/stderr formatter mismatches from being introduced going forward, without requiring a disruptive, repo-wide mass edit of ~192 files right now.

Suggested Fix

Given the scale (1,662 occurrences), do not hand-fix all existing call sites as part of this task. Instead, add a custom golangci-lint rule under pkg/linters (following the existing custom-linter pattern in this repo) that flags fmt.Fprint(ln|f)(os.Stderr, ...) wrapping a non-Stderr-suffixed Format* call, so new call sites are caught in CI going forward. A separate, larger follow-up issue can track the bulk cleanup if the team decides it's worth doing.

Code Region: pkg/console/console.go (existing *Stderr helpers), pkg/linters/ (new rule)

Suggested Agent

Developer (Go linters)

Estimated Effort

Medium (2-4 hours)

Data Source

DeepReport Intelligence Briefing, 2026-10-08 (cycle 3). Source discussion #66843. Live-verified today: the *Stderr helpers exist in pkg/console/console.go; mismatch call-site count re-confirmed at ~1,662 via grep (higher than the source report's original count — the gap is still growing).

Generated by 🔬 Deep Report · claude · agent · 343.4 AIC · ⌖ 9.25 AIC · ⊞ 7.1K · ◷

  • expires on Oct 10, 2026, 10:48 AM UTC-08:00

Activity

  1. pelikhan commented on Oct 10, 2026

    @pelikhan
    Collaborator

    Resolved by merged PR #67423: existing diagnostic formatter names now use stderr-aware styling without bulk caller renames, intentional stdout output has explicit variants, and the blocking consolestderr analyzer checks direct stdout/stderr mismatches. Mixed-TTY/NO_COLOR regressions cover both formatters and scanner, pin-callback, and bootstrap diagnostic paths. Parent issue #67143 is already closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions