Repository: vscode
Issue: Proposed API checks fail due to nullExtensionDescription when symlinks (`npm link`) is used (doc needed?)
Labels: extensions,extension-host,under-discussion

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version:
```
Version: 1.57.0-insider
Commit: 1082913dd012e21cc5f35a06f15c480ca447f67f
Date: 2021-05-27T06:55:34.773Z
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Linux x64 5.10.28-1rodete1-amd64
```
- OS Version:
Debian-derived (non-public)

Use case here is wanting to modify an extension + an npm package it depends on.
In my case, modified vscode-clangd extension with modified vscode-languageclient package.

Steps to Reproduce:
1. Clone extension ([vscode-clangd](https://github.com/clangd/vscode-clangd)) and library ([vscode-languageserver-node](https://github.com/microsoft/vscode-languageserver-node)) and install dependencies.
2. Link vscode-clangd to the checked-out vscode-languageclient in the vscode-languageserver-node repo: `cd ~/src/vscode-languageserver-node/client; npm link; cd ~/src/vscode-clangd; npm link vscode-languageclient`. This creates a symlink `~/src/vscode-clangd/node_modules/vscode-languageclient --> ~/src/vscode-languageserver-node/client`.
3. Modify the extension to use proposed API indirectly via the vscode-languageclient package (e.g. call `client.registerProposedFeatures()` on the language client)
4. Add `enableProposedApi` to the extension's package.json & run under the extension debugger in VSCode Insiders.
5. Extension fails to activate due to failed proposed-API check.

Error message:
```
Activating extension 'llvm-vs-code-extensions.vscode-clangd' failed: [nullExtensionDescription]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api nullExtensionDescription.
```

Relevant extension host log:
```
[2021-05-28 13:05:24.251] [exthost] [info] ExtensionService#_doActivateExtension llvm-vs-code-extensions.vscode-clangd {"startup":false,"extensionId":{"value":"llvm-vs-code-extensions.vscode-clangd","_lower":"llvm-vs-code-extensions.vscode-clangd"},"activationEvent":"onLanguage:cpp"}
[2021-05-28 13:05:24.251] [exthost] [info] ExtensionService#loadCommonJSModule file:///home/sammccall/src/vscode-clangd/out/src/extension
[2021-05-28 13:05:24.284] [exthost] [warning] Could not identify extension for 'vscode' require call from /home/sammccall/src/vscode-languageserver-node/client/lib/node/main.js. These are the extension path mappings: 
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/configuration-editing -> vscode.configuration-editing
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/css-language-features -> vscode.css-language-features
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/debug-auto-launch -> vscode.debug-auto-launch
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/debug-server-ready -> vscode.debug-server-ready
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/emmet -> vscode.emmet
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/extension-editing -> vscode.extension-editing
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/git -> vscode.git
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/github -> vscode.github
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/github-authentication -> vscode.github-authentication
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/grunt -> vscode.grunt
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/gulp -> vscode.gulp
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/html-language-features -> vscode.html-language-features
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/image-preview -> vscode.image-preview
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/jake -> vscode.jake
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/json-language-features -> vscode.json-language-features
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/markdown-language-features -> vscode.markdown-language-features
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/merge-conflict -> vscode.merge-conflict
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/microsoft-authentication -> vscode.microsoft-authentication
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/ms-vscode.js-debug -> ms-vscode.js-debug
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/ms-vscode.js-debug-companion -> ms-vscode.js-debug-companion
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/ms-vscode.node-debug -> ms-vscode.node-debug
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/ms-vscode.node-debug2 -> ms-vscode.node-debug2
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/ms-vscode.references-view -> ms-vscode.references-view
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/ms-vscode.remotehub -> ms-vscode.remotehub
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/ms-vscode.vscode-js-profile-table -> ms-vscode.vscode-js-profile-table
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/npm -> vscode.npm
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/php-language-features -> vscode.php-language-features
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/search-result -> vscode.search-result
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/simple-browser -> vscode.simple-browser
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/testing-editor-contributions -> vscode.testing-editor-contributions
	/home/sammccall/Downloads/VSCode-linux-x64/resources/app/extensions/typescript-language-features -> vscode.typescript-language-features
	/home/sammccall/src/vscode-clangd -> llvm-vs-code-extensions.vscode-clangd
...
[2021-05-28 10:27:30.556] [exthost] [error] Activating extension llvm-vs-code-extensions.vscode-clangd failed due to an error:
[2021-05-28 10:27:30.556] [exthost] [error] Error: [nullExtensionDescription]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api nullExtensionDescription
	at p (/home/sammccall/Downloads/VSCode-linux-x64/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:85:78741)
	at d (/home/sammccall/Downloads/VSCode-linux-x64/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:85:78688)
	at Object.get openEditors [as openEditors] (/home/sammccall/Downloads/VSCode-linux-x64/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:32523)
	at openEditorsHandler (/home/sammccall/src/vscode-languageserver-node/client/lib/common/proposed.diagnostic.js:36:48)
	at new EditorTracker (/home/sammccall/src/vscode-languageserver-node/client/lib/common/proposed.diagnostic.js:40:9)
	at new DiagnosticFeature (/home/sammccall/src/vscode-languageserver-node/client/lib/common/proposed.diagnostic.js:371:30)
	at Object.createAll (/home/sammccall/src/vscode-languageserver-node/client/lib/common/commonClient.js:59:13)
	at ClangdLanguageClient.registerProposedFeatures (/home/sammccall/src/vscode-languageserver-node/client/lib/common/commonClient.js:28:48)
	at ClangdContext.<anonymous> (/home/sammccall/src/vscode-clangd/out/src/clangd-context.js:138:25)
	at Generator.next (<anonymous>)
	at fulfilled (/home/sammccall/src/vscode-clangd/out/src/clangd-context.js:5:58)
```

Per discussion of #118812 and #118562 the proposed-API permission check uses a lookup based on the path of the source file, and `realpath()` is used, so the symlinks are lost and VSCode loses track of the fact that `vscode-languageclient`was loaded as part of this extension. Thus "nullExtensionDescription" appears rather than the actual extension name, which was the only hint what was going wrong here.

I have no idea if a different mechanism is feasible. If not maybe this limitation could be documented. This is a standard workflow when working with npm libraries, from the outside it wasn't obvious what was going wrong or how to debug, and the error messages were misleading.