Handle missing widget state metadata in WidgetsDataTypeFilter#2288
Open
hpy1968 wants to merge 2 commits into
Open
Handle missing widget state metadata in WidgetsDataTypeFilter#2288hpy1968 wants to merge 2 commits into
hpy1968 wants to merge 2 commits into
Conversation
This was referenced Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This fixes a
KeyErrorwhen notebook metadata contains the widget-state mimetype object but that object does not include a nested"state"key.Reproducer shape
When an output includes
application/vnd.jupyter.widget-view+json,WidgetsDataTypeFiltercurrently indexes:and raises:
Fix
This change treats missing
"state"the same as unavailable widget state. The filter skips the widget-view mimetype and falls back to the next available display format, such astext/plain.Tests
Tests added:
"state"falls back totext/plainTested locally:
tests/filters/test_widgetsdatatypefilter.py tests/filters/test_datatypefilter.py:5 passedtests/filters:54 passed, 5 skipped290 passed, 41 skippedRelated issues
html_exporter.from_notebook_node#2127Debugging / reproduction note
We reproduced this failure using Retrace, our Python record/replay debugger, to inspect the runtime state at the failing call site.
The replay showed that the notebook metadata contained the widget-state mimetype object, but that object only had
version_majorandversion_minor; the nested"state"key was absent. That is the shape covered by the new test.The fix and tests above do not depend on Retrace, but the replay was useful for confirming the exact runtime metadata shape behind the
KeyError.For context, we documented the replay/debugging workflow here:
https://github.com/retracesoftware/retracesoftware/tree/main/open-source-debugging/examples/001-nbconvert-1731