Skip to content

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

Closed

Description

@KuSh

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.

Activity

  1. added
    bug
    good first issue
    on Sep 8, 2026
  2. rtk-wshm-sync-bot commented on Sep 8, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟢 Priority low
    🎯 Confidence 93%

    Summary

    In ruff_cmd.rs, is_format uses args.iter().any() instead of checking args.first(), causing inconsistent passthrough truncation depending on whether 'format' appears anywhere in argv rather than as the subcommand; fix by matching is_check's pattern.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • ruff_cmd.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. Tiancheng-Xu commented on Sep 8, 2026

    @Tiancheng-Xu

    I can take this. I’ll add a focused regression test for argument routing, make the minimal first-argument fix, and open a PR shortly.

  4. KuSh commented on Oct 31, 2026

    @KuSh
    CollaboratorAuthor

    The routing change in #3968 now decides whether a command is a format run from the subcommand rtk routes on, so a bare format token elsewhere in the arguments no longer switches the filter: rtk ruff help format and rtk ruff help check both return ruff's full output on develop. That change is not in a stable release yet (the latest is v1.1.0), so this gets the resolved-pending-close label and will be closed once a release containing it ships. If it still happens on that release, please comment here.

  5. added
    resolved-pending-close
    on Oct 31, 2026
  6. KuSh commented on Nov 8, 2026

    @KuSh
    CollaboratorAuthor

    Fixed by #3968, shipped in v1.2.0: the filter is now chosen from the subcommand rtk routes on, so a bare format token elsewhere in the arguments no longer changes the output cap. With ruff 0.17.4, rtk ruff help format and rtk ruff help check both return ruff's full output. If you still see a difference on v1.2.0 or later, please comment here or reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibuggood first issuepriority:lowresolved-pending-close

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions