vscode: ERROR: unable to resolve text model content for notebook cell output

Type: Bug

When Jupyter Notebook output is truncated, an option to ‘open in a text editor’ is presented. When I do this, a new tab is opened, but it only displays a VS Code error:

The editor could not be opened due to an unexpected error: Unable to resolve text model content for resource vscode-notebook-cell-output://wsl%2Bubuntu/home/jlute/projects/Vulnscape/vulnscape/vulndig/test.ipynb#opb069b443-c48a-463a-a45a-d41950a88071%2Cvscode-remote

During troubleshooting, I discovered that the first time one uses the ‘open in a text editor’ functionality in a new notebook, the error does not occur–the text opens as expected. Subsequent attempts to ‘open in a text editor’, even for truncated output in a different cell, all result in the error moving forward.

I had other reasons to want to refresh my environment, so I also performed an entire uninstall and reinstall of WSL, VS Code, and associated Extensions, but the problem persists.

VS Code version: Code 1.81.0 (6445d93c81ebe42c4cbd7a60712e0b17d9463e97, 2023-08-02T12:37:13.485Z) OS version: Windows_NT x64 10.0.22621 Modes: Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2

System Info
Item Value
CPUs 12th Gen Intel® Core™ i7-12700H (20 x 2688)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.73GB (2.13GB free)
Process Argv
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.15.90.1-microsoft-standard-WSL2
CPUs 12th Gen Intel® Core™ i7-12700H (20 x 2688)
Memory (System) 7.62GB (5.84GB free)
VM 0%
Extensions (9)
Extension Author (truncated) Version
jupyter-keymap ms- 1.1.2
remote-wsl ms- 0.81.0
autopep8 ms- 2023.6.0
vscode-pylance ms- 2023.8.10
jupyter ms- 2023.7.1002162226
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.17
vscode-jupyter-cell-tags ms- 0.1.8
vscode-jupyter-slideshow ms- 0.1.5
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
vscaat:30438848
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vsccc:30803844
2e4cg342:30602488
89544117:30613380
showlangstatbar:30737416
vsctsb:30748421
03d35959:30757346
pythonfmttext:30731395
pythoncmv:30756943
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
gsofa:30804715
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
e537b577:30795824
dsvsc013:30795093
dsvsc014:30804076

For reference

image image

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 13
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Same issue here. Clearing output helps.

Version: 1.81.1 (user setup) Commit: 6c3e3db Date: 2023-08-09T22:22:42.175Z Electron: 22.3.18 ElectronBuildId: 22689846 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.22621

This is an effective workaround for now! Click the 3 dots > Clear Cell Outputs image

I have the same issue. For me its only that cell that is broken though. If I open a new cell and copy paste the code into the new cell, it works again (at least for a couple of executions…)

Same here. Difference is I’m on Win 10, running VS Code directly in Windows, otherwise identical versions as @vinyluis.
Extension versions:

  • Python v2023.14.0
  • Pylance v2023.8.20

To replicate:

  1. Set up environment with python 3.10.12 and these packages:
ipykernel==6.25.1
jupyter==1.0.0
jupyter-book==0.15.1
  1. Add python cell with this code:
[i for i in range(100)]
  1. Run the cell. Observe: get a truncated vertical list of numbers.
  2. Click “text editor” option at bottom of output. Observe: get a full vertical list of numbers in a new tab.
  3. Close the tab.
  4. Run the cell again, and click “text editor” option at bottom of output. Observe: get error on the lines of
The editor could not be opened due to an unexpected error: Unable to
resolve text model content for resource vscode-notebook-cell-
output:/c%3A/GitHub/Test1/test1b.ipynb#op99b16d47-a8da-4922-
a24e-f742bfaaad15%2C
  1. If I click Try Again, I get:
[Window Title]
Visual Studio Code

[Main Instruction]
Unable to open 'test1b.ipynb (output)'

[Content]
Unable to resolve text model content for resource vscode-notebook-cell-output:/c%3A/GitHub/Test1/test1b.ipynb#op99b16d47-a8da-4922-a24e-f742bfaaad15%2C

[OK] [Cancel]

If I omit step 5 (i.e. keep the editor tab open), then after subsequent re-runs of the cell I get this:

[
	{
		"metadata": {
			"outputType": "execute_result",
			"executionCount": 2,
			"metadata": {}
		},
		"outputItems": [
			{
				"mimeType": "text/plain",
				"data": "[0,\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 16,\n 17,\n 18,\n 19,\n 20,\n 21,\n 22,\n 23,\n 24,\n 25,\n 26,\n 27,\n 28,\n 29,\n 30,\n 31,\n 32,\n 33,\n 34,\n 35,\n 36,\n 37,\n 38,\n 39,\n 40,\n 41,\n 42,\n 43,\n 44,\n 45,\n 46,\n 47,\n 48,\n 49,\n 50,\n 51,\n 52,\n 53,\n 54,\n 55,\n 56,\n 57,\n 58,\n 59,\n 60,\n 61,\n 62,\n 63,\n 64,\n 65,\n 66,\n 67,\n 68,\n 69,\n 70,\n 71,\n 72,\n 73,\n 74,\n 75,\n 76,\n 77,\n 78,\n 79,\n 80,\n 81,\n 82,\n 83,\n 84,\n 85,\n 86,\n 87,\n 88,\n 89,\n 90,\n 91,\n 92,\n 93,\n 94,\n 95,\n 96,\n 97,\n 98,\n 99]"
			}
		]
	}
]

Closing the editor tab and clicking “text editor” leads to the previous error.

If I “Clear all outputs”, then the next “text editor” click works (but have to re-run the cell again).

Version: 1.81.0 (user setup) Commit: 6445d93c81ebe42c4cbd7a60712e0b17d9463e97 Date: 2023-08-02T12:37:13.485Z Electron: 22.3.18 ElectronBuildId: 22689846 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.19045

Same issue here. Clearing output helps.

Version: 1.81.1 (user setup) Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794 Date: 2023-08-09T22:22:42.175Z Electron: 22.3.18 ElectronBuildId: 22689846 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.22621

I can repro, it looks like we don’t update the update ID as new outputs are generated, but the textmodel with the old ID is disposed, so it can’t find that model. Somehow this also seems to repro in 1.80.2 and 1.79.2