Skip to content

fix: skip macOS metadata members in ZIP inputs - #5026

Open
ankit2235 wants to merge 2 commits into
docling-project:mainfrom
ankit2235:fix/zip-skip-macos-metadata
Open

ankit2235 wants to merge 2 commits into
docling-project:mainfrom
ankit2235:fix/zip-skip-macos-metadata

Conversation

@ankit2235

Copy link
Copy Markdown
Contributor

A ZIP made with macOS Finder ("Compress") also holds __MACOSX/…/._<name>
AppleDouble files and .DS_Store files. ZIP input converted each of them as a
document:

  • .DS_Store failed, so convert_all() raised ConversionError by default
    and stopped the batch.
  • __MACOSX/docs/._notes.md was converted "successfully" from binary
    metadata, which added a junk document to the results.

This change skips members under a top-level __MACOSX/ folder, members named
._*, and .DS_Store. Other unsupported members still give a failure result,
as before.

Tests: added test_macos_archive_metadata_is_skipped. It fails on main and
passes with this change. The existing ZIP tests pass unchanged.

Signed-off-by: Ankit Kumar <ankitkumar19473@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @ankit2235, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working labels Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit d43a6da680. The analysis read the diff only. It did not run code from this pull request.

The PR makes ZIP input skip macOS metadata members: files under a top-level __MACOSX/ folder, files named ._*, and .DS_Store. It adds tests for this and for a member with an empty name.

CI safety: no concern found. A maintainer must still approve CI.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI first review (advisory): blocker found

This review covers the full diff at 0df00701d9. It read the code and did not run it.

The main risk is an unhandled IndexError when a ZIP member has an empty filename and empty path parts. Check that path parts exist before index access, or use a membership check.

A maintainer makes the merge decision. This review never approves the pull request.

Comment thread docling/datamodel/document.py Outdated
@github-actions github-actions Bot added the ai:review-changes AI first review suggests changes label Oct 26, 2026
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix, we like this change: macOS-made ZIPs are a common input, and the new test reproduces the problem well.

One blocker before merge, plus two small follow-ups.

Blocker: a ZIP member named "" or "." now aborts the whole batch. For these names PurePosixPath(...).parts is (), so path.parts[0] raises IndexError. The error is raised outside the try/except around the member read, so it escapes convert_all() even with raises_on_error=False. On main, the same archive yields its other members plus a failure result for the bad entry. Details and a suggested fix are in the inline comment.

Follow-ups (non-blocking):

  • A regression case for a member with an empty name would protect the fix.
  • ._* is matched at any depth, so a real file such as docs/._real.md is now dropped silently. That is fine for AppleDouble files, but a _log.debug line per skipped member would make it traceable.

Comment thread docling/datamodel/document.py Outdated
settings of a folder as ``.DS_Store``.
"""
return (
path.parts[0] == "__MACOSX"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

path.parts is empty for a member named "" or ".", so this raises IndexError: tuple index out of range and aborts convert_all() even with raises_on_error=False.

The bot's "__MACOSX" in path.parts would also skip a legitimate nested a/__MACOSX/ folder. A slice keeps the top-level-only scope and is safe on empty parts:

Suggested change
path.parts[0] == "__MACOSX"
path.parts[:1] == ("__MACOSX",)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @dolfim-ibm! Fixed in the latest commit:

  • Used path.parts[:1] == ("__MACOSX",), so a member named "" or "." no longer raises, and only the top-level __MACOSX/ folder is skipped.
  • Added test_member_with_an_empty_name_does_not_abort_the_batch.
  • Each skipped member is now logged at debug level.

Signed-off-by: Ankit Kumar <ankitkumar19473@gmail.com>
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) and removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-changes AI first review suggests changes labels Oct 27, 2026
@ankit2235
ankit2235 requested a review from dolfim-ibm October 27, 2026 06:50

This branch has not been deployed

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

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants