rtk-ai / rtk-ai/rtk

ruff filter: `is_format` matches a bare `format` token anywhere in argv, so the passthrough cap is applied inconsistently

Open Beginner friendly
#3,928 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli bug good first issue priority:low
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

ruff_cmd.rs:

let is_format = args.iter().any(|a| a == "format");

is_check is decided from args.first(), is_format from any(). So any invocation carrying a bare format token anywhere selects filter_ruff_format for its output — and filter_ruff_format's fallback branch is a bare result.push_str(output.trim()), which skips the truncate(…, passthrough_max_chars) cap the else branch applies.

Reproduction (ruff 0.16.6, LC_ALL=C)

$ ruff help format | wc -c        # 4889
$ rtk ruff help format | wc -c    # 4889   <- uncapped
$ ruff help check | wc -c         # 6297
$ rtk ruff help check | wc -c     # 2001   <- capped at passthrough_max_chars

Two sibling invocations of the same subcommand get different caps, decided by whether the word format appears in argv. Output is correct in both cases — this is over-delivery, not loss — but the routing is accidental.

Suggested direction

Derive it from the same decision is_check_invocation makes:

let is_format = args.first().is_some_and(|a| a == "format");

Predates #3083 (which only changed is_check); it became observable there because non-check subcommands now actually reach the filter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ruff_cmd.rs by comparing the is_format decision with is_check_invocation, then run the reported ruff help format and ruff help check reproductions. Done means format is selected from the first argument consistently, with passthrough output subject to the intended cap.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.