fix(serper): ignore malformed image URLs#4319
Merged
WillemJiang merged 1 commit intoJul 21, 2026
Merged
Conversation
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
WillemJiang
approved these changes
Jul 21, 2026
yogyoho
added a commit
to yogyoho/eai-flow-main
that referenced
this pull request
Jul 22, 2026
…_detection counter clear, serper URL guard, zip colon NTFS ADS) bytedance#4295: clear _tool_name_counter on evict/reset (prevents stale counter leak across runs). bytedance#4319: wrap urlparse in try/except to ignore malformed image URLs in serper. bytedance#4236: reject colon in zip member names to close NTFS ADS smuggling gap in skill installer.
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.
Why
Serper image search normalizes provider-controlled
imageUrlandthumbnailUrlvalues through_safe_public_url(). That helper rejected unsafe schemes and private hosts, but it calledurlparse(url)directly.Python raises
ValueErrorfor malformed IPv6-style netlocs such ashttp://[::1/i.jpg, so one malformed Serper image result could abortimage_search_tool()normalization instead of being filtered out like other invalid or unsafe URLs. The sibling Brave provider already treats this case as an invalid URL and returns an empty string.Call chain / impact:
This affects only Serper image URL normalization. It does not change query construction, Serper API payloads, safe public URL acceptance, private-host filtering, or non-image search behavior.
What changed
_safe_public_url()parsing intry/except ValueError.""for malformed URLs, matching the existing invalid/unsafe URL behavior.Surface area
frontend/backend/applanggraph.json, or prompt changedocker/or sandboxed executionskills/backend/pyproject.tomlorfrontend/package.json(say what it buys us)Backend community tool provider only: this changes Serper image URL normalization under
backend/packages/harness/deerflow/community/serper.Screenshots / Recording
N/A — backend tool normalization only.
Bug fix verification
Test path that reproduces the bug:
backend/tests/test_serper_tools.py::TestSafePublicUrl::test_malformed_ipv6_url_does_not_raiseBefore the fix, the equivalent helper repro on
mainraised:After the fix, malformed provider URLs are filtered out and valid sibling image results still normalize.
Tool-level behavior proof after the fix:
{ "query": "cat", "total_results": 1, "results": [ { "title": "good", "image_url": "https://example.com/i.jpg", "thumbnail_url": "https://example.com/i.jpg" } ], "usage_hint": "Use the 'image_url' values as reference images in image generation. Download them first if needed." }Validation
uv run --project backend pytest backend/tests/test_serper_tools.py::TestSafePublicUrl— 23 passeduv run --project backend pytest backend/tests/test_serper_tools.py— 96 passeduv run --project backend ruff check backend/packages/harness/deerflow/community/serper/tools.py backend/tests/test_serper_tools.py— passeduv run --project backend ruff format --check backend/packages/harness/deerflow/community/serper/tools.py backend/tests/test_serper_tools.py— passedgit diff --check— passedAI assistance
Tool(s) used: Codex
How you used it: Identified the malformed URL repro, implemented the narrow Serper guard, added the regression test, and ran focused backend validation.