fix: handle non-image link previews - #42403
Conversation
|
Verification review — clean, no issues found. What's good:
The |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused regression coverage. The local non-image premise remains valid on current main: agent/image_routing.py:651-669 still falls back to an image MIME when magic-byte sniffing returns no result, so HTML named preview.png can be attached as image/png.
Problems
- The Open Graph implementation targets the old post-download path. Current
tools/vision_tools.py:970and:1141usetools.image_source.resolve_image_source, which rejects non-image bytes attools/image_source.py:330-337before those branches run. - The added async branches call synchronous
_validate_image_url()(tools/vision_tools.py:207-213); the URL-safety module documents that DNS work as blocking and provides an async alternative attools/url_safety.py:472-474. - The Codex routing hunk needs relocation for current main:
agent/image_routing.py:445-447returns native before a post-capability exception could run.
Suggested changes
- Rework the HTML-card behavior through the unified resolver while preserving its URL-policy and sandbox-confinement checks, with tests for both vision entry points.
- Keep recognized uncommon-image transcoding and reject only unrecognized bytes.
- Put and test the Codex exception before the capability early return.
Automated hermes-sweeper review.
| image_size_bytes = temp_image_path.stat().st_size | ||
| detected_mime_type = _detect_image_mime_type(temp_image_path) | ||
| if not detected_mime_type: | ||
| if _validate_image_url(image_url): |
There was a problem hiding this comment.
_validate_image_url() performs synchronous URL-safety/DNS work, but this branch runs inside an async function. Please use the existing async validation path (or carry forward the earlier validated resolver state) so this fallback cannot block the event loop.
Summary
Test Plan