Skip to content

fix(lsp): correctly resolve configurationPath#9323

Merged
ematipico merged 3 commits intomainfrom
fix/configuration-path-resolution
Mar 4, 2026
Merged

fix(lsp): correctly resolve configurationPath#9323
ematipico merged 3 commits intomainfrom
fix/configuration-path-resolution

Conversation

@ematipico
Copy link
Copy Markdown
Member

@ematipico ematipico commented Mar 4, 2026

Summary

Closes biomejs/biome-vscode#959
Closes #9217

I helped myself with an AI agent. I checked all the code and the comments, which make sense.

The issue was a small regression, and Biome didn't make the path absolute when users provided a relative path.

Test Plan

Added two new tests

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 360b02e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ematipico ematipico requested review from a team March 4, 2026 10:24
@github-actions github-actions bot added the A-LSP Area: language server protocol label Mar 4, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 4, 2026

Walkthrough

This PR fixes resolution of user-provided configurationPath values in the Biome LSP. It adds Session::resolve_configuration_path to convert relative configuration paths to absolute paths using workspace and file context, updates did_open to use the resolver, forces a workspace settings reload on did_change_configuration, and adds regression tests for single- and multi-root workspaces to verify relative path handling.

Possibly related PRs

Suggested labels

A-Project

Suggested reviewers

  • dyc3
  • siketyan
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarises the primary change: fixing LSP configuration path resolution for relative paths.
Description check ✅ Passed The description is directly related to the changeset, explaining the regression, referencing the linked issues, and disclosing AI assistance.
Linked Issues check ✅ Passed All coding requirements from linked issues are met: relative configurationPath resolution is implemented [#9217], and global paths now work correctly by converting to absolute paths [#959].
Out of Scope Changes check ✅ Passed All changes directly address the linked issues: session path resolution, handler invocation updates, server configuration reload, and comprehensive regression tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/configuration-path-resolution

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/biome_lsp/src/server.tests.rs (1)

4829-4857: Optional: add the positive control for test_one in the multi-root test.

You already prove test_two disables formatting; adding one quick assertion that test_one still formats would make this test harder to fool by global-state regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_lsp/src/server.tests.rs` around lines 4829 - 4857, Add a
positive control that verifies formatting is enabled for the other workspace
folder by sending a matching "textDocument/formatting" request for
"test_one/document.js" (using the same server.request and
DocumentFormattingParams pattern and uri!("test_one/document.js")) and assert
the returned Option<Vec<TextEdit>> is Some and contains at least one edit; place
this before or after the existing test_two assertion to ensure the multi-root
test checks both the disabled case (test_two) and an enabled case (test_one) to
catch regressions in global state or workspace resolution.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_lsp/src/session.rs`:
- Around line 725-733: The current logic uses workspace_roots.iter().find(...)
which returns the first matching root and can pick a parent when folders are
nested; change this to select the most specific (deepest/longest) matching root
before resolving config_path. In the block that checks file_path and uses
workspace_roots, replace the find(...) call with logic that filters roots where
file_path.starts_with(root) and then chooses the root with the greatest
depth/length (e.g., longest path string or most path components) and then return
Some(selected_root.join(&config_path)); keep the rest of the early-return
behavior the same.

---

Nitpick comments:
In `@crates/biome_lsp/src/server.tests.rs`:
- Around line 4829-4857: Add a positive control that verifies formatting is
enabled for the other workspace folder by sending a matching
"textDocument/formatting" request for "test_one/document.js" (using the same
server.request and DocumentFormattingParams pattern and
uri!("test_one/document.js")) and assert the returned Option<Vec<TextEdit>> is
Some and contains at least one edit; place this before or after the existing
test_two assertion to ensure the multi-root test checks both the disabled case
(test_two) and an enabled case (test_one) to catch regressions in global state
or workspace resolution.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7e1bb0f6-ac3b-4956-ad47-bc141d6200f5

📥 Commits

Reviewing files that changed from the base of the PR and between 1022662 and a897ddb.

📒 Files selected for processing (5)
  • .changeset/weak-boxes-look.md
  • crates/biome_lsp/src/handlers/text_document.rs
  • crates/biome_lsp/src/server.rs
  • crates/biome_lsp/src/server.tests.rs
  • crates/biome_lsp/src/session.rs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_lsp/src/session.rs`:
- Around line 693-696: The docs say load_workspace_settings should try each
workspace folder and use the first one that produces an existing config path,
but the current implementation unconditionally picks the first workspace root
(the code around the workspace root selection at lines ~743–745). Update the
resolver logic used by load_workspace_settings (and the workspace-root selection
path) to, when file_path is None, iterate workspace_folders (or the workspace
roots collection) and check for the existence of the config file in each folder,
returning the first folder whose config path exists instead of always choosing
the first workspace root; adjust the code paths referenced by
load_workspace_settings and the workspace root selection to use that
existence-check fallback.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 72e597ea-53e7-4cad-9024-47ad9179c201

📥 Commits

Reviewing files that changed from the base of the PR and between a897ddb and c6b398f.

📒 Files selected for processing (1)
  • crates/biome_lsp/src/session.rs

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
crates/biome_lsp/src/session.rs (1)

693-695: ⚠️ Potential issue | 🟠 Major

Avoid first-root roulette when file_path is absent.

Line 693 says each workspace folder is tried, but Line 741 always picks the first root. In multi-root setups, that can resolve to the wrong config and report a false missing/error state.

🔧 Suggested fix
-    /// - When `file_path` is `None` (e.g. from `load_workspace_settings`), each
-    ///   workspace folder is tried in order. The closest path to the `file_path` is used.
+    /// - When `file_path` is `None` (e.g. from `load_workspace_settings`), workspace
+    ///   folders are checked in order and the first folder where the joined path
+    ///   exists is used.
@@
-        if let Some(root) = workspace_roots.first() {
+        if let Some(root) = workspace_roots
+            .iter()
+            .find(|root| root.join(&config_path).exists())
+        {
+            return Some(root.join(&config_path));
+        }
+
+        if let Some(root) = workspace_roots.first() {
             return Some(root.join(&config_path));
         }

Also applies to: 741-743

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_lsp/src/session.rs` around lines 693 - 695, The code currently
defaults to the first workspace root when file_path is None, causing wrong
config selection in multi-root setups; update the workspace selection logic used
by load_workspace_settings (and the code that currently falls back to
base_path()) so that when file_path is None you do not unconditionally pick the
first root but instead try each registered workspace folder in order and return
the first folder that yields a valid config (or the closest match if multiple
candidates), and only if none produce a config fall back to the session's
base_path(); change the selection site that references file_path and base_path()
so it iterates and validates roots rather than always returning the first root.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@crates/biome_lsp/src/session.rs`:
- Around line 693-695: The code currently defaults to the first workspace root
when file_path is None, causing wrong config selection in multi-root setups;
update the workspace selection logic used by load_workspace_settings (and the
code that currently falls back to base_path()) so that when file_path is None
you do not unconditionally pick the first root but instead try each registered
workspace folder in order and return the first folder that yields a valid config
(or the closest match if multiple candidates), and only if none produce a config
fall back to the session's base_path(); change the selection site that
references file_path and base_path() so it iterates and validates roots rather
than always returning the first root.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 22d74b48-a677-49c0-9ab3-1ac15a587801

📥 Commits

Reviewing files that changed from the base of the PR and between c6b398f and 360b02e.

📒 Files selected for processing (1)
  • crates/biome_lsp/src/session.rs

@ematipico ematipico merged commit d5ee469 into main Mar 4, 2026
13 checks passed
@ematipico ematipico deleted the fix/configuration-path-resolution branch March 4, 2026 11:19
@github-actions github-actions bot mentioned this pull request Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LSP Area: language server protocol

Projects

None yet

2 participants