Skip to content

fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info#2134

Open
JSap0914 wants to merge 1 commit into
microsoft:mainfrom
JSap0914:fix/zip-converter-none-filename
Open

fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info#2134
JSap0914 wants to merge 1 commit into
microsoft:mainfrom
JSap0914:fix/zip-converter-none-filename

Conversation

@JSap0914

Copy link
Copy Markdown

Bug

When MarkItDown.convert_stream() is called with a ZIP stream that has no associated URL, local path, or filename (e.g. a raw io.BytesIO), the output header renders the literal Python None:

Content from the zip file `None`:

This happens because stream_info.url, stream_info.local_path, and stream_info.filename are all None, and Python f-strings format None as the string 'None'.

Fix

Fall back to '(unknown)' when all three source-info fields are absent:

# Before
file_path = stream_info.url or stream_info.local_path or stream_info.filename

# After
file_path = (
    stream_info.url
    or stream_info.local_path
    or stream_info.filename
    or "(unknown)"
)

The header now reads:

Content from the zip file `(unknown)`:

Verification

pytest packages/markitdown/tests/test_module_misc.py::test_zip_stream_no_filename_header -v
# 1 passed

AI-assisted contribution via automated tooling.

… no source info

When MarkItDown.convert_stream() is called with a ZIP stream that has no
associated URL, local_path, or filename (e.g. a raw io.BytesIO), the
ZipConverter header read:

    Content from the zip file `None`:

because stream_info.url, stream_info.local_path, and stream_info.filename
were all None and Python f-strings render None as the literal string 'None'.

Fix: fall back to '(unknown)' when all three source-info fields are absent,
producing the more descriptive:

    Content from the zip file `(unknown)`:

Add a regression test in test_module_misc.py that verifies the output does
not contain the literal string 'None' in this scenario.
Copilot AI review requested due to automatic review settings June 16, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JSap0914

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants