fix: tighten _is_image_part/_is_video_part to reject Arrow-unified None keys#42
Open
mvanhorn wants to merge 1 commit into
Conversation
…ne keys When HuggingFace datasets unify message-part schemas across image/video/text samples, every sample carries the union of part keys with None values for the keys that don't apply. _is_image_part and _is_video_part used 'in dict' checks which return True for None values, so a text-only message could match the image-part predicate and trigger downstream image-processing crashes. The fix tightens both predicates to require the corresponding key to be non-None, not just present. Helpers are imported by qwen35 + kimi_k25 so one fix covers three renderers. Fixes PrimeIntellect-ai#40
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
_is_image_partand_is_video_partinrenderers/qwen3_vl.pyusedin dictmembership checks, which returnTruefor keys withNonevalues. HuggingFace Arrow schema unification gives every sample the union of part keys withNonefor the inapplicable ones, so a text-only message was matching the image-part predicate.Why this matters
Reporter pinpointed
_is_image_partreturning True for{'text': '...', 'image_url': None, 'video_url': None}, then downstream image processing crashed on theNoneURL. The same two helpers are imported by the Qwen3.5 and Kimi-K2.5 renderers, so one fix covers three call sites.Changes
renderers/qwen3_vl.py:67-84-_is_image_partnow requirespart.get('image_url')(truthy) instead of just'image_url' in part. Same change for_is_video_partwithvideo_url.Testing
pytest tests/test_qwen3_vl.py -k _is_image_part -k _is_video_part. All four new cases pass.Fixes #40