Repository navigation
fix: IpynbConverter.accepts() catches UnicodeDecodeError on non-decodable content (fixes #1894) - #1929
Merged
Adam Fourney (afourney) merged 4 commits intoSep 2, 2026
Conversation
…files Wrap the decode block in accepts() with try/except (UnicodeDecodeError, ValueError) so that non-ASCII files (e.g. French PDFs) whose MIME type starts with 'application/json' do not crash the conversion pipeline. Fixes microsoft#1894
hanhan761
force-pushed
the
fix-1894-ipynb-unicode-decode
branch
from
May 30, 2026 07:36
84086aa to
49328c0
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The narrowed handler allows unknown charset names to raise LookupError and abort conversion.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Improves notebook detection for non-decodable content.
Changes:
- Narrows decoding exception handling in
IpynbConverter.accepts(). - Adds coverage for invalid and valid notebook content.
File summaries
| File | Description |
|---|---|
packages/markitdown/src/markitdown/converters/_ipynb_converter.py |
Handles decoding failures during notebook detection. |
packages/markitdown/tests/test_module_misc.py |
Tests binary, ASCII-incompatible, and valid notebook content. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
IpynbConverter.accepts()raisesUnicodeDecodeErrorwhen the file stream contains non-ASCII bytes that cannot be decoded as UTF-8. This crash propagates up and fails the entire conversion pipeline, even when the file is not a Jupyter notebook.Fix
Wrapped the .decode() call in accepts() with except (UnicodeDecodeError, ValueError) to gracefully return False when the content cannot be decoded.
Issue
Fixes #1894
Verification