Skip to content

ruff subcommand misrouting: rule, config, linter, etc. get check --output-format=json injected #2669

Closed

Description

@guyoron1

Bug

ruff_cmd.rs uses a blocklist to detect check invocations (lines 35-37):

let is_check = args.is_empty()
    || args[0] == "check"
    || (!args[0].starts_with('-') && args[0] != "format" && args[0] != "version");

Only format and version are excluded. All other ruff subcommands — rule, config, linter, clean, server, analyze, generate-shell-completion — are treated as check invocations and get check --output-format=json prepended.

Reproduction

rtk ruff rule E501
# Actual:  ruff check --output-format=json rule E501  (invalid command, errors out)
# Expected: ruff rule E501

rtk ruff config
# Actual:  ruff check --output-format=json config  (invalid)
# Expected: ruff config

rtk ruff linter
# Actual:  ruff check --output-format=json linter  (invalid)
# Expected: ruff linter

Root Cause

The is_check detection uses a blocklist (only "format" and "version" excluded) instead of an allowlist. Any first argument that doesn't start with - and isn't "format" or "version" is assumed to be a check target path.

Suggested Fix

Add a RUFF_SUBCOMMANDS constant (similar to NPM_SUBCOMMANDS in npm_cmd.rs) listing known ruff subcommands, and exclude them from is_check detection:

const RUFF_SUBCOMMANDS: &[&str] = &[
    "check", "format", "rule", "config", "linter",
    "clean", "server", "analyze", "version",
    "generate-shell-completion",
];

Then is_check becomes: args is empty, OR first arg is "check", OR first arg is not a known subcommand and not a flag (i.e., it's a path).

Activity

  1. added
    bug
    good first issue
    help wanted
    on Jun 27, 2026
  2. pszymkowiak commented on Jun 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 96%

    Summary

    ruff subcommands (rule, config, linter, clean, server, analyze) are misclassified as check targets and get check --output-format=json prepended, causing them to error; fix by switching from blocklist to allowlist in ruff_cmd.rs

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

    📁 Relevant files
    • src/commands/ruff_cmd.rs

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

  3. added a commit that references this issue on Jun 28, 2026
    4871169
  4. added a commit that references this issue on Jul 7, 2026
    b4b9707
  5. lntutor commented on Jul 20, 2026

    @lntutor
    Contributor

    I am working on this against current develop. I will replace Ruff's two-item blocklist with an explicit official-subcommand allowlist, keep path-style invocations routed through , and add routing tests for every affected subcommand.

  6. lntutor commented on Jul 20, 2026

    @lntutor
    Contributor

    Correction: I will replace Ruff's two-item blocklist with an explicit official-subcommand allowlist, keep path-style invocations routed through ruff check, and add routing tests for every affected subcommand.

  7. added 7 commits that reference this issue on Aug 8, 2026
    d35c13b
    fe63e15
    9b60aa1
    e4c7736
    26cb95b
    f1e07d5
    513ab6b
  8. added a commit that references this issue on Aug 14, 2026
    97405ce
  9. added 3 commits that reference this issue on Sep 16, 2026
    c9e6c3b
    58c3f05
    6469a5e
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 issuehelp wantedpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions