Skip to content

Conversation

@karrtikr
Copy link

@karrtikr karrtikr commented Aug 10, 2020

For #12962

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.0% 1.0% Duplication

@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2020

Codecov Report

Merging #13369 into master will decrease coverage by 0.06%.
The diff coverage is 16.66%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #13369 +/- ## ========================================== - Coverage 59.75% 59.68% -0.07%  ========================================== Files 670 670 Lines 37303 37347 +44 Branches 5296 5306 +10 ========================================== + Hits 22290 22291 +1  - Misses 13878 13919 +41  - Partials 1135 1137 +2 
Impacted Files Coverage Δ
src/client/common/platform/registry.ts 27.65% <12.50%> (-1.61%) ⬇️
...covery/locators/services/windowsRegistryService.ts 89.47% <25.00%> (-1.84%) ⬇️
src/client/common/utils/platform.ts 64.70% <0.00%> (-11.77%) ⬇️
src/client/datascience/crossProcessLock.ts 79.41% <0.00%> (-11.77%) ⬇️
...ient/datascience/editor-integration/codewatcher.ts 68.03% <0.00%> (-2.59%) ⬇️
src/client/linters/pydocstyle.ts 86.66% <0.00%> (-2.23%) ⬇️
src/client/datascience/debugLocationTracker.ts 76.56% <0.00%> (-1.57%) ⬇️
src/client/common/process/proc.ts 14.49% <0.00%> (-0.73%) ⬇️
src/datascience-ui/common/index.ts 95.72% <0.00%> (-0.15%) ⬇️
src/client/datascience/commands/commandRegistry.ts 34.50% <0.00%> (-0.03%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9df5ef4...776a5ad. Read the comment docs.

return getRegistryKeys({ hive: translateHive(hive)!, arch: translateArchitecture(arch), key });
return getRegistryKeys({ hive: translateHive(hive)!, arch: translateArchitecture(arch), key }).catch((ex) => {
traceError('Fetching keys from windows registry resulted in an error', ex);
return [];
Copy link
Member

Choose a reason for hiding this comment

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

Look at the getRegistryKeys implementation. We already return empty array. I don't think we will hit this case.

Copy link
Author

@karrtikr karrtikr Aug 10, 2020

Choose a reason for hiding this comment

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

async function getRegistryKeys(options: Options): Promise<string[]> {
// tslint:disable-next-line:no-require-imports
const Registry = require('winreg') as typeof import('winreg');
// https://github.com/python/peps/blob/master/pep-0514.txt#L85
return new Promise<string[]>((resolve) => {
new Registry(options).keys((error, result) => {
if (error || !Array.isArray(result)) {
return resolve([]);
}
resolve(result.filter((item) => typeof item.key === 'string').map((item) => item.key));
});
});
}

I think you're assuming that new Registry(options).keys at line 59 does not throw any errors and respects the callback. I checked the error trace user uploaded,

console.ts:137 [Extension Host] Error Python Extension: 2020-07-15 14:50:32: Get Interpreters, Class name = m, completed in 9ms, has a falsy return value, Arg 1: <Uri:c:\Users\chmay\source\mkl\mkl_email_service>, Arg 2: {"onSuggestion":true}, Return Value: undefined Error: spawn EPERM at ChildProcess.spawn (internal/child_process.js:394:11) at spawn (child_process.js:553:9) at y.keys (c:\Users\chmay\.vscode\extensions\ms-python.python-2020.6.91350\out\client\extension.js:1:621980) at c:\Users\chmay\.vscode\extensions\ms-python.python-2020.6.91350\out\client\extension.js:1:617508 at new Promise (<anonymous>) at c:\Users\chmay\.vscode\extensions\ms-python.python-2020.6.91350\out\client\extension.js:1:617483 at c.getKeys (c:\Users\chmay\.vscode\extensions\ms-python.python-2020.6.91350\out\client\extension.js:1:617615) at b.getCompanies (c:\Users\chmay\.vscode\extensions\ms-python.python-2020.6.91350\out\client\extension.js:48:796340) at b.getInterpretersFromRegistry (c:\Users\chmay\.vscode\extensions\ms-python.python-2020.6.91350\out\client\extension.js:48:795831) 

It fails at y.keys in the extension code, which is new Registry(options).keys

Copy link
Member

Choose a reason for hiding this comment

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

I see. Go it.

return getRegistryValue({ hive: translateHive(hive)!, arch: translateArchitecture(arch), key }, name).catch(
(ex) => {
traceError('Fetching key value from windows registry resulted in an error', ex);
return undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

public dispose() {}
protected async getInterpretersImplementation(_resource?: Uri): Promise<PythonInterpreter[]> {
return this.platform.isWindows ? this.getInterpretersFromRegistry() : [];
return this.platform.isWindows
Copy link
Author

Choose a reason for hiding this comment

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

I have put this just to make sure we fix the bug. We should probably have done this with all locators.

Copy link

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

This feels more like a bandaid than a full fix, but I understand the constraints here.

@karrtikr karrtikr merged commit e044a04 into microsoft:master Aug 11, 2020
@karrtikr karrtikr deleted the registry branch August 11, 2020 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants