Skip to content

fix: tighten _is_image_part/_is_video_part to reject Arrow-unified None keys#42

Open
mvanhorn wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
mvanhorn:fix/40-tighten-is-image-part-is-video-part-to-reject-arro
Open

fix: tighten _is_image_part/_is_video_part to reject Arrow-unified None keys#42
mvanhorn wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
mvanhorn:fix/40-tighten-is-image-part-is-video-part-to-reject-arro

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

_is_image_part and _is_video_part in renderers/qwen3_vl.py used in dict membership checks, which return True for keys with None values. HuggingFace Arrow schema unification gives every sample the union of part keys with None for the inapplicable ones, so a text-only message was matching the image-part predicate.

Why this matters

Reporter pinpointed _is_image_part returning True for {'text': '...', 'image_url': None, 'video_url': None}, then downstream image processing crashed on the None URL. 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_part now requires part.get('image_url') (truthy) instead of just 'image_url' in part. Same change for _is_video_part with video_url.
  • Test additions in same file: parametrized tests for Arrow-unified None case, plain text part, image part with non-None URL, video part with non-None URL.

Testing

pytest tests/test_qwen3_vl.py -k _is_image_part -k _is_video_part. All four new cases pass.

Fixes #40

…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
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.

Qwen3VLRenderer misclassifies text parts as images when content list has been through HF Dataset round-trip

1 participant