Skip to content

fix(oxlint/lsp): error on unknown command#20841

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-29-fix_lsp_error_on_unknown_command
Mar 29, 2026
Merged

fix(oxlint/lsp): error on unknown command#20841
graphite-app[bot] merged 1 commit intomainfrom
03-29-fix_lsp_error_on_unknown_command

Conversation

@Sysix
Copy link
Copy Markdown
Member

@Sysix Sysix commented Mar 29, 2026

Pull request overview

Adjusts LSP workspace command execution so unknown/unsupported commands surface as errors (instead of silently returning null), by removing the pre-dispatch “responsible tool” check and updating tests accordingly.

Copy link
Copy Markdown
Member Author

Sysix commented Mar 29, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-editor Area - Editor and Language Server C-bug Category - Bug labels Mar 29, 2026
@Sysix Sysix force-pushed the 03-29-fix_lsp_error_on_unknown_command branch from aef33ae to 5f3e68a Compare March 29, 2026 15:45
@Sysix Sysix requested a review from Copilot March 29, 2026 15:50
@graphite-app graphite-app bot changed the base branch from 03-29-refactor_lsp_accept_only_one_tool_toolbuilder to graphite-base/20841 March 29, 2026 16:21
@graphite-app graphite-app bot force-pushed the graphite-base/20841 branch from 58519df to 58012db Compare March 29, 2026 16:25
@graphite-app graphite-app bot force-pushed the 03-29-fix_lsp_error_on_unknown_command branch from 5f3e68a to 5a6b931 Compare March 29, 2026 16:25
@graphite-app graphite-app bot changed the base branch from graphite-base/20841 to main March 29, 2026 16:26
@graphite-app graphite-app bot force-pushed the 03-29-fix_lsp_error_on_unknown_command branch from 5a6b931 to 90dfc38 Compare March 29, 2026 16:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts LSP workspace command execution so unknown/unsupported commands surface as errors (instead of silently returning null), by removing the pre-dispatch “responsible tool” check and updating tests accordingly.

Changes:

  • Remove Tool::is_responsible_for_command and always delegate command execution to Tool::execute_command.
  • Update worker- and integration-level tests to expect an error for unknown commands.
  • Remove now-unused is_responsible_for_command implementations in test and linter tools.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
crates/oxc_language_server/src/worker.rs Always forwards commands to the tool; worker test updated for unknown-command error.
crates/oxc_language_server/src/tool.rs Removes responsibility hook from the Tool trait.
crates/oxc_language_server/src/tests.rs Updates LSP integration test to expect an error for invalid command.
apps/oxlint/src/lsp/server_linter.rs Removes responsibility hook implementation for the linter tool.
Comments suppressed due to low confidence (2)

apps/oxlint/src/lsp/server_linter.rs:560

  • ServerLinter::execute_command currently returns Ok(None) for unknown commands. With is_responsible_for_command removed and the PR goal being to error on unknown commands, this should return Err(ErrorCode::MethodNotFound) when command is not recognized; otherwise the LSP will still respond with a null result for invalid commands.
    /// Tries to execute the given command with the provided arguments.
    /// If the command is not recognized, returns `Ok(None)`.
    /// If the command is recognized and executed it can return:
    /// - `Ok(Some(WorkspaceEdit))` if the command was executed successfully and produced a workspace edit.
    /// - `Ok(None)` if the command was executed successfully but did not produce any workspace edit.
    ///
    /// # Errors
    /// Returns an `ErrorCode::InvalidParams` if the command arguments are invalid.
    fn execute_command(
        &self,
        command: &str,
        arguments: Vec<serde_json::Value>,
    ) -> Result<Option<WorkspaceEdit>, ErrorCode> {
        if command != FIX_ALL_COMMAND_ID {
            return Ok(None);
        }

crates/oxc_language_server/src/tool.rs:74

  • Tool::execute_command docs and default implementation still indicate unknown commands should return Ok(None), but after removing is_responsible_for_command the worker now relies on execute_command to signal unknown commands (tests expect ErrorCode::MethodNotFound). Align the contract by updating the doc comment and changing the default implementation to return Err(ErrorCode::MethodNotFound) for unrecognized commands (or otherwise document the intended behavior clearly).
    /// Tries to execute the given command with the provided arguments.
    /// If the command is not recognized, returns `Ok(None)`.
    /// If the command is recognized and executed it can return:
    /// - `Ok(Some(WorkspaceEdit))` if the command was executed successfully and produced a workspace edit.
    /// - `Ok(None)` if the command was executed successfully but did not produce any workspace edit.
    ///
    /// # Errors
    /// If there was an error executing the command, returns an `Err(ErrorCode)`.
    fn execute_command(
        &self,
        _command: &str,
        _arguments: Vec<serde_json::Value>,
    ) -> Result<Option<WorkspaceEdit>, ErrorCode> {
        Ok(None)
    }

@Sysix Sysix force-pushed the 03-29-fix_lsp_error_on_unknown_command branch from 90dfc38 to c48cfe0 Compare March 29, 2026 17:17
@Sysix Sysix changed the title fix(lsp): error on unknown command fix(oxlint/lsp): error on unknown command Mar 29, 2026
@Sysix Sysix requested a review from Copilot March 29, 2026 17:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

crates/oxc_language_server/src/tool.rs:74

  • The docs now state that unrecognized commands should return Err(ErrorCode), but the default Tool::execute_command implementation still returns Ok(None). Either update the docs to reflect the default behavior, or change the default implementation to return an error (and adjust Backend::execute_command dispatch semantics accordingly).
    /// Tries to execute the given command with the provided arguments.
    /// If the command is not recognized, returns `Err(ErrorCode)`.
    /// If the command is recognized and executed it can return:
    /// - `Ok(Some(WorkspaceEdit))` if the command was executed successfully and produced a workspace edit.
    /// - `Ok(None)` if the command was executed successfully but did not produce any workspace edit.
    ///
    /// # Errors
    /// If there was an error executing the command, returns an `Err(ErrorCode)`.
    fn execute_command(
        &self,
        _command: &str,
        _arguments: Vec<serde_json::Value>,
    ) -> Result<Option<WorkspaceEdit>, ErrorCode> {
        Ok(None)
    }

@Sysix Sysix marked this pull request as ready for review March 29, 2026 17:27
@Sysix Sysix requested a review from camc314 as a code owner March 29, 2026 17:27
@Sysix Sysix force-pushed the 03-29-fix_lsp_error_on_unknown_command branch from c48cfe0 to bdcb45e Compare March 29, 2026 17:30
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
Copy link
Copy Markdown
Contributor

camc314 commented Mar 29, 2026

Merge activity

> ## Pull request overview
>
> Adjusts LSP workspace command execution so unknown/unsupported commands surface as errors (instead of silently returning `null`), by removing the pre-dispatch “responsible tool” check and updating tests accordingly.
@graphite-app graphite-app bot force-pushed the 03-29-fix_lsp_error_on_unknown_command branch from bdcb45e to 3ef37da Compare March 29, 2026 19:51
@graphite-app graphite-app bot merged commit 3ef37da into main Mar 29, 2026
26 checks passed
@graphite-app graphite-app bot deleted the 03-29-fix_lsp_error_on_unknown_command branch March 29, 2026 19:54
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 29, 2026
graphite-app bot pushed a commit that referenced this pull request Mar 30, 2026
# Oxlint
### 💥 BREAKING CHANGES

- c0ebbce linter: [**BREAKING**] Report error on unknown builtin rule (#20464) (camc314)

### 🚀 Features

- 04f85e5 linter/no-unused-vars: Add safe-fix option for import fixes (#20839) (Marcell Toth)
- 32a3706 linter/eslint-vitest-plugin: Implements `require-test-timeout` rule (#20806) (Said Atrahouch)
- ae03653 linter: Implement suggestion for `eslint/no-useless-computed-key` rule (#20805) (Mikhail Baev)
- 6624513 linter/prefer-string-starts-ends-with: Move rule from nursery to style (#20797) (camc314)
- 58941f8 linter/prefer-readonly: Move rule from nursery to style (#20796) (camc314)
- 8837ffd linter/prefer-regexp-exec: Move rule from nursery to style (#20795) (camc314)
- 7e88871 linter/prefer-find: Move rule out of nursery (#20794) (camc314)
- ca6e5bc linter/vitest: Implement prefer-called-exactly-once-with (#17562) (Said Atrahouch)
- e80c0bf linter/eslint-plugin-vitest: Implement `require-mock-type-parameters` (#20785) (Said Atrahouch)
- cec8b8f linter/vitest: Implement require-awaited-expect-poll rule (#20702) (Said Atrahouch)
- d8e9d01 linter/eslint-plugin-vitest: Set `prefer-to-have-been-called-times` compatible with jest (#20703) (Said Atrahouch)
- caf8231 linter: Enhance import plugin diagnostics with help messages (#20766) (离谱)
- f44adfa linter: Improve the oxlint config generated by `--init`. (#20632) (connorshea)
- 43f4827 linter: Add help text to jest and promise diagnostics (#20640) (kszongic)
- 16516de linter: Enhance types for `DummyRule` (#20751) (camc314)
- 27374e8 linter: Add hint about node version when ts config fail to import (#20570) (camc314)
- 8e34150 linter/eslint-plugin-vitest: Sync rule with JS implementation (#20679) (Said Atrahouch)

### 🐛 Bug Fixes

- df057d5 linter/no-noninteractive-tabindex: Add missing composite widget … (#20860) (bab)
- bb34073 linter: Mark vitest/valid-title as a compatible jest rules (#20463) (Nicolas Le Cam)
- bd2c76b linter: Handle shadowed locals in no-restricted-globals (#20811) (Ulrich Stark)
- 62e39be linter: Sort nested object keys in fix of `eslint/sort-keys` in one pass (#20838) (Ulrich Stark)
- 3ef37da oxlint/lsp: Error on unknown command (#20841) (Sysix)
- ab1070d oxlint/cli: Skip parsing base config again for nested config search (#20809) (Sysix)
- 2be3728 oxlint/lsp: Skip parsing base config again for nested config search (#20808) (Sysix)
- 6171217 oxlint: Respect `NO_COLOR` env for `format=stylish` (#20804) (Sysix)
- d89ae8f linter/plugins: Patch `WeakMap` to emulate `WeakMap`s keyed by `sourceCode` (#20799) (overlookmotel)
- c610666 linter/no-shadow: Respect env settings when builtinGlobals is enabled (#20429) (vvnikita74)
- 6bb502f linter/no-invalid-void-type: Allow void generic args in heritage clauses (#20780) (camc314)
- 365bb7d linter: Skip typed nested literals in explicit-module-boundary-types (#20776) (camc314)
- 0aa1ff0 linter/plugins: Ensure `after` hook is always called in ESLint compat mode (#20721) (overlookmotel)
- 31145a9 linter/plugins: Fire `after` hook after CFG events in ESLint compat (#20720) (overlookmotel)
- c09a5ab diagnostics: Skip minified fallback for single-line reporters (#20716) (camc314)
- e4dc9a1 linter: Isolate `--init` config writes from parallel tests (#20717) (camc314)
- 7e394ec linter: Clarify empty replacement fixer help text (#20698) (camc314)
- d15a99c linter/jsx-curly-brace-presence: Flag empty string literals (#20690) (camc314)

### 📚 Documentation

- c722495 linter: Update JS Plugins + LS references (#20843) (camc314)
- e1f9748 linter/jsdoc/require-property: Fix typo (#20792) (Benjaming61001)
- be3dcc1 linter: Add note about node version + custom TS plugin (#19381) (camc314)
# Oxfmt
### 🚀 Features

- 6ef440a oxfmt: Support bool for object style options (#20853) (leaysgur)
- 23050fa oxfmt: Support markdown-in-js substitution (#20683) (leaysgur)
- 4087295 oxfmt: Support angular-in-js substitution (#20676) (leaysgur)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-editor Area - Editor and Language Server A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants