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

Preferences Schema should ignore preferences that cannot be dendrified #12004

Closed
colin-grant-work opened this issue Dec 16, 2022 · 4 comments
Closed
Labels
bug bugs found in the application preferences issues related to preferences

Comments

@colin-grant-work
Copy link
Contributor

colin-grant-work commented Dec 16, 2022

Bug Description:

For use in plugins and the editor, preferences need to be able to be properly dendrified, i.e. transformed into an object tree where keys with . are transformed into multiple objects:

{
  "a.b": true,
  "a.c": false
}

Becomes

{
  a: {
    b: true,
    c: false,
  }
}

As a consequence, it must not be permitted that any preference key be an extension of another preference key with a value:

{
  "a": "already has a value!"
  "a.b": "now I can't be a key of object a!"
}

Internally, VSCode is careful to ensure that that doesn't happen, but Theia is not as strict, so problems can occur if plugins don't play by the rules. See here, for example.

Steps to Reproduce:

  1. Install clang-format
  2. Start the application.
  3. See an error TypeError: Cannot create property 'windows' on string 'clang-format'

Additional Information

  • Operating System: RHEL7, Electron
  • Theia Version: 1.28
@colin-grant-work colin-grant-work added bug bugs found in the application preferences issues related to preferences labels Dec 16, 2022
@tsmaeder
Copy link
Contributor

So does clang-format is trying to set an illegal value or how does this happen? You can't provoke it by writing into settings.json, can you?=

@colin-grant-work
Copy link
Contributor Author

colin-grant-work commented Dec 21, 2022

It shouldn't be possible to get the error just by writing something bad in your settings.json because we ignore anything in the settings.json that isn't part of the schema - you need a bad schema to get the error. clang-format has written their preference schema so that there exist (they think) these keys:

clang-format.executable
clang-format.executable.windows
clang-format.executable.osx
clang-format.executable.linux`

But that can't be dendrified. VSCode recognizes that clang-format.executable has to be a leaf because it has type string, so it ignores the rest. We currently don't ignore the rest, so when we try to dendrify the structure, we try to say the equivalent of 'clang-format'.windows = 'clang-format', and an error gets thrown.

@dhuebner
Copy link
Member

dhuebner commented Jan 11, 2024

@colin-grant-work @tsmaeder
The new ConfigurationModelParser introduced here handles key conflicts.
In the current master I see following errors logged:
2024-01-11T13:52:30.444Z root ERROR [hosted-plugin: 96058] Conflict in settings file Default: Ignoring clang-format.executable.windows as clang-format.executable is "clang-format"

I think this can be closed as fixed.

@tsmaeder
Copy link
Contributor

Your wish is my command, @dhuebner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application preferences issues related to preferences
Projects
None yet
Development

No branches or pull requests

3 participants