Skip to content

Spec should discourage abuse of initializationOptions and didChangeConfiguration #567

Description

I'm working on having Eclipse IDE adopting some language servers.
I see a possible bad trend for Language Servers to heavily rely on initializationOptions and didChangeConfigurations to enable/disable features. The issue with those is that they are unspecified placeholders and that whatever usage is made of it requires all clients to write code specific to this language server to support those options.
The main example I have in mind right now is RLS that, by abusing those settings is progressively, and most likely without really willing it, breaking rich compatibility with other IDEs: rust-lang/rls#1047
Abuse of those properties should be deprecated in the spec, with some disclaimer explaining how relying on those make the LS integration less likely to be trivially portable from an editor to another.

Activity

  1. rcjsuen commented on Sep 10, 2018

    @rcjsuen
    Contributor

    Interesting. I use workspace/didChangeConfiguration as that's what was there but did not consider this case.

    At what point would you consider the use of this "abuse" though?

  2. mickaelistria commented on Sep 10, 2018

    @mickaelistria
    Author

    As an adopter of LS I don't develop, I consider any usage is abuse, as long as it requires to create a specific UI or workflow to interact with it in the client ;) But I hope this discussion can lead to a more flexible definition.

  3. LaurentTreguier commented on Sep 10, 2018

    @LaurentTreguier
    Contributor

    As I see it, a server initialized without initializationOptions should just work in any editor. If the editor allows servers to be started by custom extensions with possible deeper integration (like VSCode or Atom for example), then initializationOptions can be used to enable specific features that can't be used in other editors.

  4. mickaelistria commented on Sep 10, 2018

    @mickaelistria
    Author

    Laurent Tréguier (@LaurentTreguier): so your proposal is that the settings should be limited to only client-specific configuration? I think it'd be fair.

  5. LaurentTreguier commented on Sep 10, 2018

    @LaurentTreguier
    Contributor

    This is how I understood it. The spec describes it as User provided initialization options, which can be misleading; it makes it sound like the user should change it themselves when it should be up to a specific client to do this.

  6. dbaeumer commented on Sep 12, 2018

    @dbaeumer
    Member

    IMO the spec should encourage all server providers to spec the following to things:

    • the initialization options it supports. I agree with Laurent Tréguier (@LaurentTreguier) that a server should work with an empty literal as well and simply assume a set of defaults.
    • which workspace/configuration request it sends.

    Having a push model for configurations was a mistake and got basically replaced by the pull model where the server sends workspace/configuration requests.

    The client should still send workspace/didChangeConfiguration notification so that the server can clear caches if it caches configurations. But it should not send any values since values can differ based on the scope used in the workspace/configuration request.

  7. mickaelistria commented on Sep 12, 2018

    @mickaelistria
    Author
  8. dbaeumer commented on Sep 13, 2018

    @dbaeumer
    Member

    I disagree here. The reason is that the fact that initializationOptions is in the spec say that this property should be used and not any other random property.

    I still think that it is a fair thing to require a server to depend on some initializationOptions. But I do fully agree that these need to be speced by the server (and not be reverse engineered from code) and that server should work with a resonable default set if they are not provided. Same is true for settings.

    I do fully agree that the spec need to spec this assumptions.

    Martin Aeschlimann (@aeschli) any comments on why the CSS language server can't work with a reasonable default set ?

  9. felixfbecker commented on Nov 16, 2018

    @felixfbecker

    One pattern I saw emerge is that many language servers interpret initializationOptions as containing user configuration, i.e. the same that is sent in workspace/didChangeConfiguration or in response to workspace/configuration. But LSP doesn't actually really say this, it is very vague on what initializationOptions actually means:

    User provided initialization options.

    It doesn't use the term "configuration", but it does say "user provided" (not client provided).

    The reason why language servers use it for configuration is because there is otherwise no way to read configuration in initialize. workspace/didChangeConfiguration is only sent after initialize returned (if at all), and workspace/configuration is not among the whitelisted requests allowed during initialize.
    The problem is that since initializationOptions is not clearly defined, most clients do not send configuration in it.
    Could LSP just be clearer about what initializationOptions is intended to be used for (maybe with an example in the spec)? And could workspace/configuration be whitelisted to be used during initialize?

  10. dbaeumer commented on Dec 18, 2018

    @dbaeumer
    Member

    I will clarify the spec in a way that the initializationOptions is typically something that could be passed on the command line when starting the server. It shouldn't be user configurations.

    I am actually against whitelisting workspace/configuration. If a server needs the configuration to register providers it should use dynamic registration instead of static registration which allows to mix workspace/configuration with registration calls.

  11. dbaeumer commented on Dec 18, 2018

    @dbaeumer
    Member

    Please ping if you think dynamic registration is not the right path to go.

  12. mickaelistria commented on Dec 18, 2018

    @mickaelistria
    Author
  13. felixfbecker commented on Dec 18, 2018

    @felixfbecker

    I am actually against whitelisting workspace/configuration. If a server needs the configuration to register providers it should use dynamic registration instead of static registration which allows to mix workspace/configuration with registration calls.

    Dirk Bäumer (@dbaeumer) I agree for determining whether a provider should be registered or not, but a server might need configuration during initialisation for a lot of reasons. For example, a loglevel or logfile, whether file watchers should be set up with polling or OS events, the HTTP endpoint of a service that needs to be contacted, whether dependencies should be installed, if yes an access token for that, the path of an external tool that needs to be shelled into, something like JAVA_HOME or GOPATH, ...
    Requiring to delay all of these after initialize complicates a lot of things for no apparent reason. Also not every client supports dynamic registration, and these clients should gracefully degrade in functionality, i.e. they should work with a static set of capabilities from server initialize and work with restarting the server instead of not working at all.

  14. 35 remaining items

  15. dbaeumer commented on Apr 1, 2020

    @dbaeumer
    Member

    Alex Kladov (@matklad) Why would that be any different than initializationOptions Or do you simply suggest a different name. Typing wise it would still be any.

  16. matklad commented on Apr 1, 2020

    @matklad
    Contributor

    For two reasons:

    • it will guarantee to submit the same values as the workspace/configuration
    • clients would be able to automatically populate it from settings, instead of needing custom per-language code to constuct initializationOptions

    I guess we can just reuse existing initializationOptions key, and just make sure that it automatically gets populated from the settings.

  17. dbaeumer commented on Oct 28, 2021

    @dbaeumer
    Member

    It is possible to send getConfiguration requests in the initialized notification.

    I will close the issue since I am really not a fan of having another property during initialization. Please ping if you think otherwise.

  18. removed this from the Backlog milestone on Nov 2, 2021
  19. michaelpj commented on Mar 7, 2022

    @michaelpj
    Contributor

    It is possible to send getConfiguration requests in the initialized notification.

    The current spec says

    In addition the server is not allowed to send any requests or notifications to the client until it has responded with an InitializeResult, with the exception that during the initialize request the server is allowed to send the notifications window/showMessage, window/logMessage and telemetry/event as well as the window/showMessageRequest request to the client.

    Which seems to contradict what you said, Dirk Bäumer (@dbaeumer) ?

  20. rwols commented on Mar 7, 2022

    @rwols
    Contributor

    No this contradicts nothing.

    1. initialize is a request sent from client to server.
    2. initialized is a notification from the client. Clients are expected to send this notification after receiving a response to the initialize request.

    A server can therefore do a workspace/configuration request in its handler for initialized notifications.

  21. michaelpj commented on Mar 7, 2022

    @michaelpj
    Contributor

    Gotcha, thanks!

  22. nayeemrmn commented on Apr 30, 2024

    @nayeemrmn

    I will look into white listing workspace/configuration.

    It is possible to send getConfiguration requests in the initialized notification.

    Dirk Bäumer (@dbaeumer) The latest solution doesn't seem sufficient and I think workspace/configuration should be allow-listed during initialize.

    Good servers should pull relevant workspace settings by namespace, for each workspace folder if interested, and incorporate that before they start processing normal document notifications/requests. Currently you can only do that in the initialized handler. This means every server must have a boilerplate initializer lock which blocks out other message handling until that part of the initialized handler is completed.

    Is that the basic recommended approach? Or are servers supposed to initialize once with default settings, initialize again with pulled config slightly later while possibly receiving doc info in between? I don't see any other interpretation.

    Well, extension authors have avoided this and are still heavily relying on initializationOptions for startup workspace settings despite using pull-based config when it comes to receiving workspace/didChangeConfiguration. IMO that should only be a fallback for clients that don't support pull-based config, if they're worth the effort. My problem is that initializationOptions has no convention for per-workspace-folder settings.

    Is there a good reason to not allow-list workspace/configuration?

  23. michaelpj commented on Apr 30, 2024

    @michaelpj
    Contributor

    Is that the basic recommended approach? Or are servers supposed to initialize once with default settings, initialize again with pulled config slightly later while possibly receiving doc info in between?

    This is what we're doing in HLS. In fact we do all of what you said:

    • Start with default config
    • Take the config from intializationOptions if it's there
    • Fire off workspace/configuration in the initialized handler

    I agree that this is not very good, and it certainly seems that if you do the recommended thing you can start getting sent requests before you have your config set up.

  24. aon012345 commented on May 1, 2024

    @aon012345

    good

  25. dbaeumer commented on May 6, 2024

    @dbaeumer
    Member

    Is there a good reason to not allow-list workspace/configuration?

    In general I try to keep the message that can be sent to the client in initialized as small as possible to make the initialization phase on the client simple.

    Currently you can only do that in the initialized handler

    I usually do that when actually processing a request and then cache the result of the workspace/configuration. When I receive a workspace/didChangeConfiguration I simply clear the cache.

  26. nayeemrmn commented on May 6, 2024

    @nayeemrmn

    I usually do that when actually processing a request and then cache the result of the workspace/configuration.

    This is not a good candidate for lazy init because:

    • workspace/configuration generally is behind an async binding, and accessing config shouldn't need to be.
    • It spreads to other structures that depend on config. Now everything must be computed lazily and asynchronously.
    • Lazy computation is used to make things more responsive. In this case it's less responsive compared to acting on workspace/didChangeConfiguration.

    In general I try to keep the message that can be sent to the client in initialized as small as possible to make the initialization phase on the client simple.

    I think that would mean just storing the initialize params and returning server info and capabilities, since technically everything else can be done lazily. But server authors won't use it that way.

    A more meaningful differentiation is that initialize is the request that all other requests are blocked on, hinting that it should get up-to-date everything required for handling textDocument/* notifications. That makes more sense so server authors are using it that way (but relying on initializationOptions).

    Please reconsider allow-listing workspace/configuration during initialize.

  27. added a commit that references this issue on Feb 1, 2026
    545cd69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions