Repository navigation
fix(prettier): read check results from stderr, never report a failing check as success - #117
Merged
Merged
Conversation
… check as success Prettier >= 1.19 writes its --check results ([warn] <file>) to stderr, but the filter ran with RunOptions::stdout_only() and also explicitly skipped any line containing [warn]. On a failing check the file list was silently discarded and the filter produced 'Prettier: All files formatted correctly' alongside exit code 1. - filter the combined stdout+stderr stream - recognize '[warn] <file>' lines as files needing formatting - exit-aware guard: a check that exited non-zero with no parsable file list passes the real output through instead of claiming success
Prettier 3.x colors the [warn] marker even when its output is piped
(observed through rtk's own capture on Windows: '[\x1b[33mwarn\x1b[39m]'),
so the literal strip_prefix("[warn]") never matched real output and every
failing check fell through to the raw passthrough guard. Strip ANSI from
the whole input first, matching the strip_ansi convention used by other
filters (git, uv, binlog, glab).
Regression test uses the ANSI sequence captured from a real
'rtk prettier --check' run.
Co-Authored-By: Claude Fable 5 <[email protected]>
Review round: one invariant — a run that signals failure never yields the success line. Failure is non-zero exit, or prettier's own 'Code style issues found' verdict for callers that have no exit code to give. - rtk format prettier had result.exit_code in hand and discarded it at the filter dispatch; pass it through filter_prettier_output_with_exit - guard the previously unguarded 'All matched files use Prettier' early return (stray success summary beside a non-zero exit) - the pipe path (no exit code, text only) is covered by the textual verdict - add the checklist-required count_tokens >=60% savings test Co-Authored-By: Claude Fable 5 <[email protected]>
Owner
Author
Review round (pre-merge)Three passes ran on Findings and outcomes (all fixed in
Not acted on: the extension allow-list if-cascade shape (cosmetic, pre-existing, out of scope). Gate re-run after fixes: fmt + clippy + test --all + release build, all clean (2711 unit tests, 12 prettier tests). |
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.
Adopts upstream rtk-ai/rtk#3571 by @guyoron1. Closes #105.
Bug
Prettier >= 1.19 writes
--checkresults ([warn] <file>) to stderr, but the filter ran withRunOptions::stdout_only()and additionally skipped any line containing[warn]. On a failing check the file list was discarded and the check-mode branch producedPrettier: All files formatted correctlybeside exit code 1 — a truth inversion. On current develop thenever_worseguard usually masked the false success down to a bareChecking formatting...(zero signal on stdout), with the raw[warn]lines only surviving via the runner's rtk-ai#3026 stderr passthrough.Commits
34946b7[warn] <file>, exit-aware guard: non-zero exit with no parsable file list passes real output through instead of claiming success6f4d9f7[warn]marker even when piped, so the literalstrip_prefix("[warn]")never matched real output and every failing check fell through to raw passthrough. Onestrip_ansicall at filter entry, matching the convention used by git/uv/binlog/glab filters. Regression test uses the captured real ANSI sequence.59f2564Code style issues foundverdict for callers with no exit code — never yields the success line. Plumbsresult.exit_codethroughrtk format prettier(it was discarded at the dispatch), guards the previously unguardedAll matched files use Prettierearly return, covers the exit-code-less pipe path via the textual verdict, and adds the checklist-requiredcount_tokens≥60% savings test.Repro (real binary, Windows)
bad.js=const x=1, prettier 3.x installed locally,rtk prettier --check bad.js.Before (installed rtk, pre-fix develop):
File list absent from stdout; summary claims nothing; the only signal is raw ANSI-laden stderr.
After (branch build):
Success case unchanged:
good.js→Prettier: All files formatted correctly, exit 0.Call-site analysis
filter_prettier_outputhas three callers; after the review round each one enforces the failure invariant:prettier_cmd::run— real exit code viarun_filtered_with_exit(cherry-pick).format_cmd::run(rtk format prettier) — hadresult.exit_codein hand and discarded it; now passes it throughfilter_prettier_output_with_exit(review round).pipe_cmd::resolve_filter— exit code structurally unavailable (piped text); covered by the textualCode style issues foundfailure signal (review round).Cluster / deliberately not fixed
Check/ListDifferent/Passthrough, +134/−16). Not adopted: the ticket names fix(prettier): never report a failed run as formatted rtk-ai/rtk#3571, which fixes the verified mechanism with a quarter of the blast radius. fix: avoid false prettier success output rtk-ai/rtk#2410's remaining value (arg-based mode routing,--list-differenthandling) is separable follow-up work.[warn]skip — collapsing it into aconstarray is cosmetic and out of scope.Quality gate
Clean: zero clippy warnings, 20 test suites all green (2711 unit tests incl. 12 prettier tests, 7 of them new), release build OK (x86_64-pc-windows-msvc host toolchain). Re-run in full after the review round.