Skip to content

fix(diagnostic): include config path and CWD in ConfigurationOutsideProject#9488

Open
mvanhorn wants to merge 5 commits intobiomejs:mainfrom
mvanhorn:osc/9463-improve-config-outside-cwd-message
Open

fix(diagnostic): include config path and CWD in ConfigurationOutsideProject#9488
mvanhorn wants to merge 5 commits intobiomejs:mainfrom
mvanhorn:osc/9463-improve-config-outside-cwd-message

Conversation

@mvanhorn
Copy link

Summary

The "Biome found a configuration file outside of the current working directory" diagnostic now includes the actual configuration file path and working directory. Previously the message had no dynamic content, leaving users with no actionable information to debug the issue.

Before:

Biome found a configuration file outside of the current working directory.

After:

Biome found the configuration file "/home/user/.config/biome.json" outside of the current working directory "/home/user/project".

Both CLI and LSP code paths are updated.

Fixes #9463

Test Plan

  • cargo check -p biome_lsp -p biome_cli passes
  • Diagnostic struct now takes config_path and working_directory fields

AI Assistance

This PR was written with AI assistance (Claude Code).

…roject

The error message "Biome found a configuration file outside of the
current working directory" now includes the actual configuration file
path and the working directory. This gives users actionable information
to debug the issue.

Fixes biomejs#9463

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Mar 15, 2026

🦋 Changeset detected

Latest commit: 19f3ec6

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

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-LSP Area: language server protocol labels Mar 15, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 54c56ade-2c87-44c5-bbdc-e9f9d125e464

📥 Commits

Reviewing files that changed from the base of the PR and between 79d801c and 19f3ec6.

⛔ Files ignored due to path filters (1)
  • crates/biome_cli/tests/snapshots/main_cases_configuration/can_read_configuration_from_user_home.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_cli/src/runner/mod.rs
  • crates/biome_lsp/src/session.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_lsp/src/session.rs
  • crates/biome_cli/src/runner/mod.rs

Walkthrough

The PR expands the ConfigurationOutsideProject diagnostic to include two public fields, config_path: String and working_directory: String, and removes the Default derive. Call sites in the CLI runner and the LSP session now capture and supply the config file path (falling back to "<unknown>" when needed) and compute a working-directory string; control flow and public signatures remain unchanged. Diagnostic message text was updated to reference the new fields.

Possibly related PRs

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding config path and CWD to the ConfigurationOutsideProject diagnostic message.
Description check ✅ Passed The description clearly explains the problem, solution, and provides concrete before/after examples of the diagnostic message.
Linked Issues check ✅ Passed The PR fully addresses issue #9463 by including both the configuration file path and working directory in the diagnostic message across CLI and LSP code paths.
Out of Scope Changes check ✅ Passed All changes are directly scoped to improving the ConfigurationOutsideProject diagnostic message as specified in the linked issue.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.

OpenGrep is compatible with Semgrep configurations. Add an opengrep.yml or semgrep.yml configuration file to your project to enable OpenGrep analysis.

Copy link
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: 2

🤖 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_cli/src/runner/mod.rs`:
- Around line 390-398: The diagnostic is showing the directory path instead of
the actual config file path; change the construction of config_path_str to use
the loaded config file path variable (rather than directory_path) and fall back
to "<unknown>" if that file path is missing, then pass that into
PrintDiagnostic::simple(&ConfigurationOutsideProject { config_path:
config_path_str, working_directory: working_dir.to_string() }). Locate where
config_path_str is built (currently from directory_path.as_ref().map(|p|
p.to_string()).unwrap_or_else(...)) and replace that expression with the actual
config file path variable (e.g., config_path or config_file) converted to
string.

In `@crates/biome_lsp/src/session.rs`:
- Around line 979-985: The logged working_directory is derived directly from
ConfigurationPathHint variants and can be incorrect for FromUser and
FromUserExternal; update the logic that computes working_directory in session.rs
to reuse the same resolution used later for the effective project base (extract
or call the shared helper that resolves the base path used for project loading)
so that working_directory reflects the actual resolved base (ensure the code
paths around where ConfigurationPathHint is matched and where the effective
project base is computed both use the same resolver or helper function).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7ec74a85-247b-49b4-9f2c-9658072e8986

📥 Commits

Reviewing files that changed from the base of the PR and between fe9ff6b and a9b974a.

📒 Files selected for processing (3)
  • crates/biome_cli/src/runner/mod.rs
  • crates/biome_lsp/src/session.rs
  • crates/biome_service/src/diagnostics.rs

mvanhorn and others added 2 commits March 15, 2026 08:45
Show the actual configuration file path in the ConfigurationOutsideProject
diagnostic instead of just the directory path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
let config_path_str = config_file_path
.as_ref()
.map(|p| p.to_string())
.unwrap_or_else(|| "<unknown>".to_string());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.unwrap_or_else(|| "<unknown>".to_string());
.unwrap_or("<unknown>".to_string());

Copy link
Author

Choose a reason for hiding this comment

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

Applied in 3d4d125.

&root_configuration_dir
};
if !loaded_location.is_in_project() {
let config_path_str = config_file_path
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let config_path_str = config_file_path
let config_file_path = config_file_path

Copy link
Author

Choose a reason for hiding this comment

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

Applied in 3d4d125.

console.log(markup! {
{PrintDiagnostic::simple(&ConfigurationOutsideProject)}
{PrintDiagnostic::simple(&ConfigurationOutsideProject {
config_path: config_path_str,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
config_path: config_path_str,
config_path: config_file_path,

Copy link
Author

Choose a reason for hiding this comment

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

Applied in 3d4d125.

- Apply ematipico's code suggestions: rename config_path_str to
  config_file_path, use unwrap_or, update struct field reference.
- Fix LSP working directory resolution for FromUser/FromUserExternal
  config hints: resolve to parent directory for file paths and use
  session base path for external configs, matching the project_path
  resolution logic below.
@ematipico
Copy link
Member

@mvanhorn linting and tests don't pass. Please make sure to test things locally

- Use map_or_else instead of map().unwrap_or_else() in session.rs
- Update can_read_configuration_from_user_home snapshot for new message format
- Verified tests and clippy pass locally
@mvanhorn
Copy link
Author

Fixed in 19f3ec6: resolved the clippy map_unwrap_or lint in session.rs and updated the snapshot for the new diagnostic message format. Tests and clippy pass locally now.

AI disclosure: this PR uses Claude Code for implementation.

@ematipico
Copy link
Member

CI is failing...

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

Labels

A-CLI Area: CLI A-LSP Area: language server protocol A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Improve error message: Biome found a configuration file outside of the current working directory.

2 participants