Repository navigation
Conversation
|
✅ DCO Check Passed Thanks @ryanmeowy, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
a794ec3 to
82d6486
Compare
AI triage (advisory)Checked commit This pull request prevents conversion failures when processing pictures with unsupported Pillow modes, such as CMYK, LAB, or F, or when processing truncated image data. It normalizes image modes to PNG-compatible formats and catches decoding exceptions in CI safety: no concern found. A maintainer must still approve CI. 1 related pull request(s) in the same code
The |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@ryanmeowy The PR #4681 , which addresses issue #4680 , was open earlier on this same topic. |
|
Thanks @ceberam, and thanks @usmanmateen — I hadn't seen #4681 when opening this one; we clearly hit the same root cause independently. How it differs: the two hunks in Does it resolve #4682 and #4680? Yes to both. #4680's repro (CMYK + truncated JPEG in HTML/Markdown) succeeds here. #4682 additionally documents the MHTML drop (fixed by the Gaps: the Tests: #4681's are unit-level (direct loader calls); ours run end-to-end through Happy to defer to #4681 since it was opened first — two ways: (a) I close this and move the MHTML fix + end-to-end tests into a follow-up PR on top of it, or (b) if you prefer a single PR, this one is a strict superset of #4681. Either works for me; I only care that the MHTML path doesn't stay broken. |
|
Thanks @ryanmeowy for your review. |
82d6486 to
2a6bd02
Compare
|
Thanks @usmanmateen — your cross-review made this easy for everyone: verifying the MHTML gap against your own branch is exactly the diligence that settles a duplicate. Carrying over |
ceberam
left a comment
There was a problem hiding this comment.
Thanks @ryanmeowy for the PR. The fix is correct, the code is clean, and the tests are meaningful. Please address the suggestions below, plus a minor inconsistency note.
|
Hi @ceberam — sorry to ping you directly, and apologies if this is a bad time. Just a gentle bump on #4683. I think I've covered everything from your review: I dropped the provenance comment, added the explicit Small extra ask, only if it's easy: #4745's latest commit is stuck in Thanks, and sorry again for the nudge. |
There was a problem hiding this comment.
Thanks @ryanmeowy for the heads-up. It all seems good but there are actually some conflicts after we merged some PRs recently. Could you please rebase to main and address them?
2981226 to
628a576
Compare
628a576 to
83a84e9
Compare
|
@ceberam Rebased onto |
|
@ryanmeowy Can you fix the merge conflict? |
ImageRef.from_pil() serializes to PNG, so images in CMYK, LAB or F mode raise OSError: cannot write mode <mode> as PNG. In the shared ImageResourceLoader.create_image_ref() that error is not in the except tuple, so it escaped and aborted the whole conversion for the HTML, Markdown, AsciiDoc and JATS backends. In the MHTML branch of html_backend the error is caught, so the picture was silently dropped instead. Normalize the image first, as the Office backends already do, and catch OSError so that a single unreadable image can never fail a conversion. Unit test for the truncated-image (OSError) path carried over from PR 4681 by @usmanmateen. Co-authored-by: usmanmateen <usmanmateen255@gmail.com> Signed-off-by: Ryan Yang <ryanxys@gmail.com>
Single-source the loader coverage: keep one end-to-end HTML check and the MHTML check for the PNG-mode normalization, dropping the Markdown and AsciiDoc variants that only re-exercise the DocumentConverter plumbing, and delete the dedicated test module in favor of the existing backend suites. Call img.load() in create_image_ref for parity with the MHTML and OpenDocument paths. Drop the provenance comment; attribution is tracked in the commit trailer. Signed-off-by: Ryan Yang <ryanxys@gmail.com>
83a84e9 to
5e46d36
Compare
|
@PeterStaar-IBM Fixed — rebased onto |
Issue resolved by this Pull Request:
Resolves #4682
Checklist:
tests/test_backend_html.pyand one intests/test_backend_mhtml.py; a unit test for the truncated-image path, carried over from fix(html): keep CMYK images and skip undecodable ones instead of failing #4681 by @usmanmateen, lives intests/test_image_resource_loader.py.Review evidence:
Behavior before. A picture in CMYK, LAB or F mode raised
OSError: cannot write mode <mode> as PNGinsideImageRef.from_pil(). The sharedImageResourceLoader.create_image_ref()did not catchOSError, so the error escaped and aborted the whole conversion for the HTML, Markdown, AsciiDoc and JATS backends. The MHTML branch caught the error and dropped the picture. On the JATS backend the error also stopped the body walk, so the conversion lost all body content after the figure and still reported success.Behavior after. The loader normalizes the picture first, as the Office backends already do. The
excepttuple also catchesOSError. CMYK, LAB and F pictures are now kept and converted to RGB, through the embedded ICC profile when one is present. A picture that cannot be decoded no longer fails a conversion. The backend keeps the picture placeholder and emits a warning.Checks.
pytest tests/test_backend_html.py tests/test_backend_mhtml.py tests/test_image_resource_loader.pypytest tests/test_backend_msword.py tests/test_backend_msword_lists.py tests/test_backend_msword_outline.py tests/test_backend_msword_spacer.py tests/test_backend_opendocument.py tests/test_office_image_modes.py tests/test_backend_image_native.py tests/test_api_image_request.pyruff format --check .andruff check .ty checkmain(line shifts only)Not run: conversion of real print-scanned document corpora, and the remote-fetch path of the loader (the test URL allowlist blocks it).