Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify users for invalid client settings #16361

Merged
merged 2 commits into from
Feb 27, 2025

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Feb 25, 2025

Summary

As mentioned in #16296 (comment)

This PR updates the client settings resolver to notify the user if there are any errors in the config using a very basic approach. In addition, each error related to specific settings are logged.

This isn't the best approach because it can log the same message multiple times when both workspace and global settings are provided and they both are the same. This is the case for a single workspace VS Code instance.

I do have some ideas on how to improve this and will explore them during my free time (low priority):

  • Avoid resolving the global settings multiple times as they're static
  • Include the source of the setting (workspace or global?)
  • Maybe use a struct (ResolvedClientSettings + Vec<ClientSettingsResolverError>) instead to make unit testing easier

Test Plan

Using:

{
  "ruff.logLevel": "debug",
	
  // Invalid settings
  "ruff.configuration": "$RANDOM",
  "ruff.lint.select": ["RUF000", "I001"],
  "ruff.lint.extendSelect": ["B001", "B002"],
  "ruff.lint.ignore": ["I999", "F401"]
}

The error logs:

2025-02-27 12:30:04.318736000 ERROR Failed to load settings from `configuration`: error looking key 'RANDOM' up: environment variable not found
2025-02-27 12:30:04.319196000 ERROR Failed to load settings from `configuration`: error looking key 'RANDOM' up: environment variable not found
2025-02-27 12:30:04.320549000 ERROR Unknown rule selectors found in `lint.select`: ["RUF000"]
2025-02-27 12:30:04.320669000 ERROR Unknown rule selectors found in `lint.extendSelect`: ["B001"]
2025-02-27 12:30:04.320764000 ERROR Unknown rule selectors found in `lint.ignore`: ["I999"]

Notification preview:

Screenshot 2025-02-27 at 12 29 06 PM

@dhruvmanila dhruvmanila added the server Related to the LSP server label Feb 25, 2025
@dhruvmanila dhruvmanila changed the title Expand ruff.configuration to allow inline config Notify users for invalid client settings Feb 25, 2025
Copy link
Contributor

github-actions bot commented Feb 25, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Base automatically changed from dhruv/server-configuration to main February 26, 2025 04:47
@dhruvmanila dhruvmanila force-pushed the dhruv/server-warn-invalid-settings branch from b912715 to 487eff0 Compare February 27, 2025 06:47
@dhruvmanila dhruvmanila force-pushed the dhruv/server-warn-invalid-settings branch from 487eff0 to ac84820 Compare February 27, 2025 06:59
@dhruvmanila dhruvmanila marked this pull request as ready for review February 27, 2025 07:02
@dhruvmanila dhruvmanila force-pushed the dhruv/server-warn-invalid-settings branch from 3ee184c to 55c4768 Compare February 27, 2025 08:24
@dhruvmanila dhruvmanila force-pushed the dhruv/server-warn-invalid-settings branch from 55c4768 to bd4a0ad Compare February 27, 2025 08:24
@dhruvmanila dhruvmanila enabled auto-merge (squash) February 27, 2025 08:25
@dhruvmanila dhruvmanila merged commit d56d241 into main Feb 27, 2025
20 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/server-warn-invalid-settings branch February 27, 2025 08:28
dcreager added a commit that referenced this pull request Feb 28, 2025
* main:
  [red-knot] Switch to a handwritten parser for mdtest error assertions (#16422)
  [red-knot] Disallow more invalid type expressions (#16427)
  Bump version to Ruff 0.9.9 (#16434)
  Check `LinterSettings::preview` for version-related syntax errors (#16429)
  Avoid caching files with unsupported syntax errors (#16425)
  Prioritize "bug" label for changelog sections (#16433)
  [`flake8-copyright`] Add links to applicable options (`CPY001`) (#16421)
  Fix string-length limit in documentation for PYI054 (#16432)
  Show version-related syntax errors in the playground (#16419)
  Allow passing `ParseOptions` to inline tests (#16357)
  Bump version to 0.9.8 (#16414)
  [red-knot] Ignore surrounding whitespace when looking for `<!-- snapshot-diagnostics -->` directives in mdtests (#16380)
  Notify users for invalid client settings (#16361)
  Avoid indexing the project if `configurationPreference` is `editorOnly` (#16381)
dcreager added a commit that referenced this pull request Feb 28, 2025
* dcreager/alist-type:
  Remove unneeded shear override
  Update property test CI
  Move alist into red_knot_python_semantic
  [red-knot] Switch to a handwritten parser for mdtest error assertions (#16422)
  [red-knot] Disallow more invalid type expressions (#16427)
  Bump version to Ruff 0.9.9 (#16434)
  Check `LinterSettings::preview` for version-related syntax errors (#16429)
  Avoid caching files with unsupported syntax errors (#16425)
  Prioritize "bug" label for changelog sections (#16433)
  [`flake8-copyright`] Add links to applicable options (`CPY001`) (#16421)
  Fix string-length limit in documentation for PYI054 (#16432)
  Show version-related syntax errors in the playground (#16419)
  Allow passing `ParseOptions` to inline tests (#16357)
  Bump version to 0.9.8 (#16414)
  [red-knot] Ignore surrounding whitespace when looking for `<!-- snapshot-diagnostics -->` directives in mdtests (#16380)
  Notify users for invalid client settings (#16361)
  Avoid indexing the project if `configurationPreference` is `editorOnly` (#16381)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Related to the LSP server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants