Skip to content

fix(tsc): guard "No errors found" behind exit code - #3295

Closed
NekomyaDev wants to merge 1 commit into
rtk-ai:developfrom
NekomyaDev:fix-tsc-false-positive-dev
Closed

NekomyaDev wants to merge 1 commit into
rtk-ai:developfrom
NekomyaDev:fix-tsc-false-positive-dev

Conversation

@NekomyaDev

Copy link
Copy Markdown

Closes #3220. (Re-targeted to develop per CONTRIBUTING.md — supersedes #3294.)

Problem

TscHandler::format_summary ignored the process exit code: whenever zero parseable TS#### errors were captured, it returned TypeScript: No errors found — even when tsc exited non-zero without emitting parseable diagnostics (e.g. missing tsconfig.json, invalid compiler flags, fatal config errors like TS5058). The filter could therefore report success on a failed run.

Fix

format_summary now guards on exit_code:

  • exit_code == 0 + no parseable errors → unchanged: TypeScript: No errors found
  • exit_code != 0 + no parseable errors → reports TypeScript: failed (exit code N) with no parseable TS errors and appends the last 10 non-empty lines of raw output so the fatal diagnostic (which the streaming filter otherwise drops) stays visible

Tests

Two new regression tests:

  • test_tsc_stream_failure_without_parseable_errors — non-zero exit with only a fatal TS5058 line must not contain "No errors found", must surface exit code and the fatal line
  • test_tsc_stream_success_still_reports_no_errors — zero exit with empty output still reports "No errors found"

All existing tsc streaming/filter tests are unaffected (the success path is unchanged).

@HetCreep

HetCreep commented Aug 4, 2026

Copy link
Copy Markdown

Two notes for whoever reviews this, from an external audit of v0.44.2 (700bdde) that landed on the same defect.

Provenance: AI-assisted source audit, human-directed. Source and git log only — I did not build either branch.

There are currently three PRs for this one bug

They are not conflicting approaches so much as the same change at two levels of detail, which may be why both are sitting. For what it is worth from the outside, appending the raw tail is the part that matters most to the actual consumer here — an agent that sees only compilation failed (exit 2) will usually re-run the command to find out why, which costs more than the tokens the filter saved. But that is the reviewer's call, and either is strictly better than the current behaviour.

The pattern this restores already exists in the tree, one directory over

src/cmds/rust/cargo_cmd.rs:99 implements the same BlockHandler::format_summary contract and already gates its success line on the exit code:

if self.error_count == 0 && self.warnings == 0 && exit_code == 0

That guard was added in 39a4d28 (2026-07-03), "fix(cargo): …". tsc_cmd.rs:80's unguarded return Some("TypeScript: No errors found\n") has been unchanged since b82fa85 (2026-01-29) — so this is a fix that landed for one handler and did not propagate to its sibling, rather than a new class of bug. Worth citing in the PR body: it gives the reviewer an in-tree precedent to compare against instead of evaluating the change cold.

The same shape recurs beyond tsc — go vet is the one I looked at closely (src/cmds/go/go_cmd.rs:117, where the build path got run_filtered_with_exit in f69ad6e and vet did not); I have written that up on #2281. #2317 tracks the general case.

No objection to this PR — posting only so the duplicate-PR situation and the 39a4d28 precedent are visible in one place.

@AlvinManojAlex

Copy link
Copy Markdown

Does this PR solve the bug, or is still a work-in-progress?

@KuSh

KuSh commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this. Develop already guards the summary on the exit code: #2232 (merged 2026-08-29) reworked TscHandler::format_summary so a non-zero exit with no parseable diagnostics reports "compiler exited with code N, but RTK parsed no diagnostics" and prints the raw output instead of "No errors found", and it closed the same issue #3220. It also strips ANSI from the dumped lines and keeps both ends of long output rather than only the tail, and carries regression tests for the non-zero-exit and clean-exit paths. Closing as covered, but please comment or reopen if you see a case that still slips through.

@KuSh KuSh closed this Sep 6, 2026
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.

tsc filter: "TypeScript: No errors found" is printed on a non-zero exit, so a tsc that never ran reads as a clean typecheck

4 participants