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

Incorrect conversions from null to undefined in new RPC #11392

Closed
colin-grant-work opened this issue Jul 7, 2022 · 2 comments · Fixed by #11396
Closed

Incorrect conversions from null to undefined in new RPC #11392

colin-grant-work opened this issue Jul 7, 2022 · 2 comments · Fixed by #11396
Labels
bug bugs found in the application core issues related to the core of the application

Comments

@colin-grant-work
Copy link
Contributor

colin-grant-work commented Jul 7, 2022

Bug Description:

In certain cases, null values from the backend are appearing on the frontend as undefined.

Steps to Reproduce:

  1. Install and activate the vscode-lldb plugin.
  2. See error mentioned here: Failure to activate because of problem in a method startRpcServer.

The error does not occur in 1.26 (without new RPC) but does in 1.27 with new RPC.


You can also use this plugin (source). Assuming you have not set the preference peaSoup.secretIngredients, running the command Access a (probably) non-existent preference should show a toast with the default value null, but on master it shows [].

Additional Information

The relevant preference is defined here with a default of null. However, when the plugin's data is transmitted to the frontend, that null becomes undefined, and we enter this code:

getDefaultValue(property: PreferenceItem): JSONValue {
if (property.defaultValue !== undefined) {
return property.defaultValue;
}
if (property.default !== undefined) {
return property.default;
}
const type = Array.isArray(property.type) ? property.type[0] : property.type;
switch (type) {
case 'boolean':
return false;
case 'integer':
case 'number':
return 0;
case 'string':
return '';
case 'array':
return [];
case 'object':
return {};
}
// eslint-disable-next-line no-null/no-null
return null;
}

Because the preference is typed as ["object", "null"], that method returns a default of {} rather than the configured default of null.

I have confirmed that null is present here, but becomes undefined when received here.

  • Operating System: MacOS 12.4
  • Theia Version: 1.27.0
@colin-grant-work
Copy link
Contributor Author

colin-grant-work commented Jul 7, 2022

Attn: @JonasHelming, @tortmayr

@colin-grant-work colin-grant-work added bug bugs found in the application core issues related to the core of the application labels Jul 7, 2022
@JonasHelming
Copy link
Contributor

@tortmayr

tortmayr added a commit to eclipsesource/theia that referenced this issue Jul 8, 2022
tortmayr added a commit to eclipsesource/theia that referenced this issue Jul 8, 2022
Fixes eclipse-theia#11392

Contributed on behalf of STMicroelectronics
tortmayr added a commit to eclipsesource/theia that referenced this issue Jul 8, 2022
Fixes eclipse-theia#11392

Contributed on behalf of STMicroelectronics
JonasHelming pushed a commit that referenced this issue Jul 11, 2022
Fixes #11392

Contributed on behalf of STMicroelectronics
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 core issues related to the core of the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants