Repository navigation
Conversation
Collaborator
✅ Integration test reportCommit: 4c21236
Top 33 slowest tests (at least 2 minutes):
|
Contributor
Author
|
/review |
| // use. Whether err supports color depends only on this cmdIO's capabilities, | ||
| // so the result does not change; the color depth is read from ctx's | ||
| // environment on that first call. (sync.OnceValue can't take ctx.) | ||
| func (c *cmdIO) stderrWriter(ctx context.Context) io.Writer { |
There was a problem hiding this comment.
RenderDiagnostics in render.go:475 writes to c.err directly, and its template color functions (renderFuncMap → colorEnabled → SupportsStdoutColor) decide color the same way cmdio.Yellow does — based on stdout. So databricks bundle validate 2>/tmp/diag.log with stdout on a terminal still leaks escapes into the file. Should it also write through stderrWriter, or is that planned for a later PR in the stack?
pietern
force-pushed
the
pietern/charm-v2/02b-logstring-strip
branch
from
November 18, 2026 13:07
cef5a26 to
4c21236
Compare
pietern
force-pushed
the
pietern/charm-v2/02b-logstring-strip
branch
from
November 18, 2026 15:55
4c21236 to
3f78fb3
Compare
LogString writes text that callers styled for stdout (cmdio.Yellow and friends check stdout's color support). With stdout a terminal and stderr redirected, those escapes used to reach the file. LogString now writes through the stderr renderer's Writer, which strips escapes when stderr does not support color. The writer is built once per cmdIO. Stderr that is a terminal is unchanged, including under CI or CLICOLOR=0: cmdio only checks NO_COLOR and TERM=dumb for color, and the renderer keeps the profile termenv reports for a terminal. Golden changes (both pins run stderr as a pipe, so the strip applies): - TestStderrPin_LogStringStyles/stdout-tty-stderr-redirected: the helper row loses its SGR, "helper: red". - TestColorPin_Swatch, the eight color environments (ci, clicolor-0, colorterm-yes, term-screen, term-unset, term-vt100, term-xterm-256color, tmux-truecolor): the helpers row loses its SGR. no-color and term-dumb were already plain. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
pietern
force-pushed
the
pietern/charm-v2/02b-logstring-strip
branch
from
November 18, 2026 16:07
3f78fb3 to
fb9edd2
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
cmdio.LogStringwrites through the stderr renderer'sWriter, which strips escape sequences when stderr does not support color. The stderr writer is built once per cmdIO (stderrWriter), so concurrent first calls agree on it. Changelog fragment:.nextchanges/cli/stderr-strip-color.md.What is stripped: messages written with
LogString(warnings, hints and similar), when stderr is a file or pipe and stdout is a terminal. Callers style those messages withcmdio.Yellowand similar helpers, which check stdout's color support, so the styles used to reach a redirected stderr.What is not stripped: a stderr that is a terminal keeps its color, including with
CIorCLICOLOR=0set. cmdio checks onlyNO_COLORandTERM=dumbfor color, and stderr's renderer keeps the profile termenv reports for a terminal.Why
Redirected stderr should not carry escape codes meant for the terminal. The strip is in its own PR so that the output change is reviewable on its own; it changes two pin rows.
Tests
go build ./..., golangci-lint (0 issues), gofmt clean.TERM=xterm-256color go test -race -count=3 ./libs/cmdio/...passes, includingTestLogStringConcurrent,TestLogStringStripsStylesOnColorlessStderr.TestStderrPin_LogStringStyles/stdout-tty-stderr-redirected: the helper row loses its SGR (helper: \x1b[31mred\x1b[0mbecomeshelper: red).TestColorPin_Swatch, the eight color environments (ci,clicolor-0,colorterm-yes,term-screen,term-unset,term-vt100,term-xterm-256color,tmux-truecolor): the helpers row loses its SGR. The pin's stderr is a pipe, so the strip applies.no-colorandterm-dumbwere already plain.selftest tui colors(default stream, which goes throughLogString), stdout a terminal, stderr redirected to a file: before this PR the file had SGR, after it had none, with the default environment,CI=1andCLICOLOR=0. With stderr on the terminal, both builds keep the SGR under all three.Stack: based on
pietern/charm-v2/02a-renderer.Manual checks for real terminals:
databricks selftest tui colors 2>/tmp/err.txt; cat -v /tmp/err.txt: no escape codes in the file.databricks selftest tui colors: colors on the terminal, unchanged.CI=1 databricks selftest tui colors: stderr on the terminal keeps its colors; the same with2>/tmp/err.txtstrips.This pull request and its description were written by Isaac.