Fix notebook metadata loss when using remote Jupyter Server kernels #16954
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where
language_info
metadata was being deleted from notebooks when reopening them with remote Jupyter Server kernels.Problem
When using a remote Jupyter server (e.g.,
jupyter notebook --NotebookApp.token='FooBar123'
), the following workflow would result in metadata loss:language_info
metadata gets deleted:Root Cause
The issue was in
src/kernels/execution/helpers.ts
in theupdateNotebookMetadataWithSelectedKernel
function. When no local Python interpreter information was available (which is typical for remote kernels), the code would clear thelanguage_info
metadata even though it contained valid information from the remote server.Solution
Modified the logic to preserve existing
language_info
metadata for remote kernels (startUsingRemoteKernelSpec
andconnectToLiveRemoteKernel
) when no local interpreter information is available. The fix:language_info
for local kernels where missing interpreter info might indicate stale datalanguage_info
from remote servers that was previously saved with the notebookTesting
Added comprehensive test cases covering both remote kernel scenarios:
RemoteKernelSpecConnectionMetadata
without interpreterLiveRemoteKernelConnectionMetadata
without interpreterAll existing tests continue to pass, ensuring no regressions in local kernel behavior.
Fixes #16207.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
0.0.0.123
node /home/REDACTED/work/vscode-jupyter/vscode-jupyter/node_modules/.bin/mocha --config ./build/.mocha.unittests.js.json ./out/interactive-window/generatedCodeStorageManager.unit.test.js ./out/interactive-window/shiftEnterBanner.unit.test.js ./out/kernels/helpers.unit.test.js ./out/kernels/kernelAutoReConnectMonitor.unit.test.js ./out/kernels/kernelAutoRestartMonitor.unit.test.js ./out/kernels/kernelCrashMonitor.unit.test.js ./out/kernels/kernelDependencyService.unit.test.js ./out/kernels/kernelFinder.unit.test.js ./out/kernels/kernelProvider.node.unit.test.js ./out/kernels/kernelProvider.web.unit.test.js ./out/kernels/kernelRefreshIndicator.node.unit.test.js ./out/kernels/kernelRefreshIndicator.web.unit.test.js ./out/test/package.nls.json.unit.test.js out/kernels/execution/helpers.unit.test.js
(packet block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.