Skip to content

Commit 6b3714d

Browse files
author
Syed Shahmeer Ali
committed
Fix: Remove widgets metadata causing GitHub rendering issues
- Removed problematic widgets metadata from 11 affected notebooks - Fixes issue #398: 'Invalid Notebook' error on GitHub - Notebooks affected: 27, 31, 32, 33, 34, 35, 37, 40, 41, 44, 46 - Added comprehensive documentation of the fix - All notebooks remain fully functional and now render correctly on GitHub Closes #398
1 parent 0b6ab51 commit 6b3714d

12 files changed

+1579
-36392
lines changed

FIX_DOCUMENTATION.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Fix Documentation: Jupyter Notebook Rendering Issue #398
2+
3+
## 🐛 Problem Statement
4+
Multiple Jupyter notebooks in the haystack-tutorials repository were displaying "Invalid Notebook" errors when viewed on GitHub, preventing users from reading the tutorials directly on the platform.
5+
6+
## 🔍 Root Cause Analysis
7+
The issue was caused by malformed `widgets` metadata in the notebook JSON structure. GitHub's notebook renderer expected a specific format for the widgets metadata:
8+
9+
### Expected Structure (GitHub Compliant):
10+
```json
11+
{
12+
"metadata": {
13+
"widgets": {
14+
"application/vnd.jupyter.widget-state+json": {
15+
"state": {
16+
"widget_id_1": { ... },
17+
"widget_id_2": { ... }
18+
},
19+
"version_major": 2,
20+
"version_minor": 0
21+
}
22+
}
23+
}
24+
}
25+
```
26+
27+
### Actual Structure (Problematic):
28+
```json
29+
{
30+
"metadata": {
31+
"widgets": {
32+
"application/vnd.jupyter.widget-state+json": {
33+
"widget_id_1": {
34+
"model_module": "...",
35+
"state": { ... }
36+
},
37+
"widget_id_2": {
38+
"model_module": "...",
39+
"state": { ... }
40+
}
41+
}
42+
}
43+
}
44+
}
45+
```
46+
47+
**Issue**: Missing top-level `state` key that GitHub expected in the widgets metadata structure.
48+
49+
## 🛠️ Solution Implemented
50+
Removed the entire `widgets` metadata section from all affected notebooks. This approach was chosen because:
51+
52+
1. **Safe**: Widget metadata only stores interactive widget state, not notebook functionality
53+
2. **Clean**: Eliminates the malformed structure completely
54+
3. **Non-breaking**: All notebook code, outputs, and content remain intact
55+
4. **Effective**: Resolves GitHub rendering issues immediately
56+
57+
## 📊 Impact Summary
58+
59+
### Files Modified (11 total):
60+
- `tutorials/27_First_RAG_Pipeline.ipynb`
61+
- `tutorials/31_Metadata_Filtering.ipynb`
62+
- `tutorials/32_Classifying_Documents_and_Queries_by_Language.ipynb`
63+
- `tutorials/33_Hybrid_Retrieval.ipynb`
64+
- `tutorials/34_Extractive_QA_Pipeline.ipynb`
65+
- `tutorials/35_Evaluating_RAG_Pipelines.ipynb`
66+
- `tutorials/37_Simplifying_Pipeline_Inputs_with_Multiplexer.ipynb`
67+
- `tutorials/40_Building_Chat_Application_with_Function_Calling.ipynb`
68+
- `tutorials/41_Query_Classification_with_TransformersTextRouter_and_TransformersZeroShotTextRouter.ipynb`
69+
- `tutorials/44_Creating_Custom_SuperComponents.ipynb`
70+
- `tutorials/46_Multimodal_RAG.ipynb`
71+
72+
### Statistics:
73+
- **36,392 deletions**: Problematic widgets metadata removed
74+
- **1,468 insertions**: JSON formatting adjustments
75+
- **0 functional changes**: No code logic altered
76+
77+
## ✅ Verification Steps Completed
78+
79+
1. **JSON Validation**: All notebooks load as valid JSON
80+
2. **Metadata Check**: Confirmed no `widgets` metadata remains
81+
3. **Content Integrity**: All cells, outputs, and code preserved
82+
4. **Functionality Test**: Notebooks remain executable
83+
84+
## 🎯 Result
85+
All affected notebooks now render correctly on GitHub, resolving issue #398 completely.
86+
87+
## 🔧 Technical Details
88+
89+
### Error Message (Before Fix):
90+
```
91+
"Invalid Notebook: the 'state' key is missing from 'metadata.widgets'. Add 'state' to each, or remove 'metadata.widgets'."
92+
```
93+
94+
### Validation (After Fix):
95+
```python
96+
import json
97+
for notebook in affected_notebooks:
98+
data = json.load(open(notebook))
99+
assert 'widgets' not in data.get('metadata', {})
100+
print(f"{notebook}: Fixed and validated")
101+
```
102+
103+
## 📝 Commit Information
104+
- **Branch**: `fix-jupyter-widgets-metadata-issue-398`
105+
- **Commit Hash**: `d05210b`
106+
- **Closes**: Issue #398
107+
108+
---
109+
**Fix Date**: August 24, 2025
110+
**Contributors**: @SyedShahmeerAli12
111+
**Review Status**: Ready for PR submission

0 commit comments

Comments
 (0)