ulysses/services/search
Lucas Daniel fa7c4f8ea9
fix(search): catch HTTPStatusError so 403/404 URLs degrade gracefully instead of 500 (#2203)
raise_for_status() raises httpx.HTTPStatusError for 4xx/5xx responses,
but the surrounding try/except only caught httpx.RequestError (network
errors) and RateLimitError (429). Any other HTTP error code propagated
uncaught up through chat_processor -> chat_helpers -> chat_routes and
surfaced as a 500 Internal Server Error.

Added an explicit except httpx.HTTPStatusError clause that logs a warning
and returns an empty result, matching the behaviour already in place for
network errors.

Also adds focused regression tests that exercise the real
fetch_webpage_content() path with a mocked _get_public_url:
- 403/404 responses return the standard empty-result shape instead of
  raising, proving the new HTTPStatusError handling works end to end.
- 429 responses still take their own dedicated rate-limit branch (the
  status_code == 429 check runs before raise_for_status() is reached),
  keeping that behaviour distinct from the new generic HTTPStatusError
  handling.

Dropped the unrelated builtin_mcp.py change that had been carried over
from a rebase; that fix is tracked separately in #2018 and this branch
should stay scoped to the search content fetch path.

Closes #2148
2026-06-08 01:09:21 +01:00
..
__init__.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
analytics.py fix: search analytics FileHandler crashes on startup writing to read-only image layer (#2366) 2026-06-07 19:26:22 +02:00
cache.py fix(search): write cache under DATA_DIR, guard mkdir against read-only path (#3334) 2026-06-07 22:37:12 +01:00
content.py fix(search): catch HTTPStatusError so 403/404 URLs degrade gracefully instead of 500 (#2203) 2026-06-08 01:09:21 +01:00
core.py fix: web search content blocks numbered by fetch completion order break citations (#1672) 2026-06-03 14:22:55 +09:00
providers.py fix(search): degrade to empty results on non-JSON provider responses (#1129) (#1352) 2026-06-03 14:24:23 +09:00
query.py fix: _extract_entities crashes on a non-string query (#1724) 2026-06-03 13:30:28 +09:00
ranking.py Word-boundary match for snippet and subject-term ranking (#1473 follow-up) (#2556) 2026-06-05 08:04:31 +01:00
service.py fix: SearchService.search() calls comprehensive_web_search incorrectly (broken public API) (#1720) 2026-06-03 13:33:56 +09:00