Skip to content

Fix #3364: web search robustness - handle non-2xx responses and filter search engine self-links - #3365

Merged
Yeachan-Heo merged 3 commits into
mainfrom
fix/issue-3364-d23w1255
Oct 23, 2026
Merged

Yeachan-Heo merged 3 commits into
mainfrom
fix/issue-3364-d23w1255

Conversation

@Yeachan-Heo

Copy link
Copy Markdown
Contributor

Fixes the bug reported in issue #3364 where DuckDuckGo challenge pages (HTTP 202 or similar without proper search result markup) would return junk results pointing back to DuckDuckGo itself.

Changes

  • Add HTTP status code check to execute_web_search: return explicit error if response is not 2xx (e.g., 202 Accepted, 429 Too Many Requests, etc.) instead of proceeding with potentially invalid results
  • Filter out links pointing back to the search engine host in the generic link fallback to avoid returning search engine self-links
  • Keep CLAWD_WEB_SEARCH_BASE_URL behavior working unchanged
  • Add regression tests for both scenarios

What this fixes

  • When the search provider returns a non-success HTTP status, web search now fails with a clear error message instead of fabricating junk results
  • When the search provider returns HTML without proper search result markup, the generic link fallback now filters out links back to the search engine itself

Refs #3364

Note: The optional provider proposal from #3364 (CLAWD_WEB_SEARCH_PROVIDER=keenable) is left for maintainer review as a separate product decision.

…ters search engine self-links

- Add HTTP status code check to execute_web_search: return error if response is not 2xx
  instead of proceeding with potentially junk results (e.g., DuckDuckGo challenge pages)
- Filter out links pointing back to the search engine host in extract_search_hits_from_generic_links
  to avoid returning search engine self-links when no proper search results are found
- Add regression tests for both scenarios

Refs #3364
clawdbot added 2 commits October 23, 2026 13:13
…responses

- Replace exact host matching with registrable domain comparison to properly
  filter search engine self-links across subdomains (e.g., html.duckduckgo.com
  vs duckduckgo.com)
- Add error handling for 2xx responses with no search results (e.g., 202
  challenge pages from blocked search providers)
- Add regression tests for both 202 challenge page and mixed self-link scenarios
- Remove unrelated Cargo.lock version bumps (revert to 0.1.6)

Fixes #3364
…ine links

The challenge page arrives as HTTP 202, which is_success() accepts, and its
links point at duckduckgo.com while the request goes to html.duckduckgo.com,
so the previous filter kept them. Only a 200 page is parsed now, and the
generic fallback drops any duckduckgo.com link or link to the configured
search host. Removes the registrable-domain heuristic and the 'no hits is an
error' path (a real query can legitimately return nothing), and replaces
tests that never exercised a self-link with ones that fail on the old code.

Refs #3364
@Yeachan-Heo
Yeachan-Heo marked this pull request as ready for review October 23, 2026 13:22
@Yeachan-Heo
Yeachan-Heo merged commit fd8527f into main Oct 23, 2026
6 checks passed
@Yeachan-Heo
Yeachan-Heo deleted the fix/issue-3364-d23w1255 branch October 23, 2026 13:57
@Yeachan-Heo Yeachan-Heo mentioned this pull request Oct 23, 2026
@XinwangTao

Copy link
Copy Markdown

Thanks for the fix — rejecting non-2xx responses instead of extracting junk from DuckDuckGo challenge pages, plus dropping self-referencing search-engine links, matches the symptom we hit (every connection returning HTTP 202). One note: the opt-in keyless API backend proposal from the triage issue is still unaddressed — worth tracking it as a separate issue so the 202 handling and the API backend stay decoupled.

1 similar comment
@XinwangTao

Copy link
Copy Markdown

Thanks for the fix — rejecting non-2xx responses instead of extracting junk from DuckDuckGo challenge pages, plus dropping self-referencing search-engine links, matches the symptom we hit (every connection returning HTTP 202). One note: the opt-in keyless API backend proposal from the triage issue is still unaddressed — worth tracking it as a separate issue so the 202 handling and the API backend stay decoupled.

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.

2 participants