microsoft / vscode-isort

Import sorting for python using the isort library.
https://marketplace.visualstudio.com/items?itemName=ms-python.isort
MIT License
87 stars 21 forks source link

TypeError: Cannot read properties of null (reading 'map') #77

Closed karthiknadig closed 2 years ago

karthiknadig commented 2 years ago
[2022-06-21 10:42:13.425] [renderer1] [error] Cannot read properties of null (reading 'map'): TypeError: Cannot read properties of null (reading 'map')
    at g (/home/buda/.vscode/extensions/ms-python.isort-2022.3.11671003/dist/extension.js:1:213014)
    at Object.asCodeAction (/home/buda/.vscode/extensions/ms-python.isort-2022.3.11671003/dist/extension.js:1:223954)
    at /home/buda/.vscode/extensions/ms-python.isort-2022.3.11671003/dist/extension.js:1:152688
    at async U.provideCodeActions (/opt/visual-studio-code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:103131)

Filed by @SandroJijavadze here https://github.com/microsoft/vscode-isort/issues/53#issuecomment-1161312695

karthiknadig commented 2 years ago
  ERR Cannot read properties of null (reading 'map'): TypeError: Cannot read properties of null (reading 'map')
    at asDiagnostics (c:\GIT\formatters\vscode-isort\dist\webpack:\isort\node_modules\vscode-languageclient\lib\common\protocolConverter.js:34:1)
    at Object.asCodeAction (c:\GIT\formatters\vscode-isort\dist\webpack:\isort\node_modules\vscode-languageclient\lib\common\protocolConverter.js:598:1)
    at c:\GIT\formatters\vscode-isort\dist\webpack:\isort\node_modules\vscode-languageclient\lib\common\client.js:1226:1
    at A.provideCodeActions (c:\Users\Karthik Nadig\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:92:42766)

This seems to occur due to us returning code actions even when it is not needed. In def code_action_organize_imports(params: lsp.CodeActionParams) in server.py we return both organize and quick fix code actions in all cases. We should only be retrning quickfix if one is needed. We should not be returning the organize code action when providing a quickfix.

gagandeepp commented 2 years ago

@karthiknadig interested please assign

antonag32 commented 2 years ago

Also happening to me.

[2022-10-19 22:55:18.779] [exthost] [error] [ms-python.isort] provider FAILED
[2022-10-19 22:55:18.779] [exthost] [error] TypeError: Cannot read properties of null (reading 'map')
    at g (/home/odoo/.vscode-server/extensions/ms-python.isort-2022.2.0/dist/extension.js:1:212952)
    at Object.asCodeAction (/home/odoo/.vscode-server/extensions/ms-python.isort-2022.2.0/dist/extension.js:1:223892)
    at /home/odoo/.vscode-server/extensions/ms-python.isort-2022.2.0/dist/extension.js:1:152626
    at async A.provideCodeActions (/home/odoo/.vscode-server/bin/64bbfbf67ada9953918d72e1df2f4d8e537d340e/out/vs/workbench/api/node/extensionHostProcess.js:92:42766)
LeuschkeTressa commented 2 years ago

My debug log (Output -> Log (Window)) is littered with these messages.

Seems to be related: https://github.com/microsoft/vscode-isort/issues/18

One of the messages:

[2022-10-21 14:25:33.369] [renderer1] [error] Cannot read properties of null (reading 'map'): TypeError: Cannot read properties of null (reading 'map')
    at g (/Users/<user>/.vscode/extensions/ms-python.isort-2022.2.0/dist/extension.js:1:213014)
    at Object.asCodeAction (/Users/<user>/.vscode/extensions/ms-python.isort-2022.2.0/dist/extension.js:1:223954)
    at /Users/<user>/.vscode/extensions/ms-python.isort-2022.2.0/dist/extension.js:1:152688
    at A.provideCodeActions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:92:42766)

VS Code versions:

Version: 1.72.2
Commit: d045a5eda657f4d7b676dedbfa7aab8207f8a075
Date: 2022-10-12T22:15:55.763Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: No