fix(docker): preserve single-url crawl failure details - #2117
fix(docker): preserve single-url crawl failure details#2117nightcityblade wants to merge 1 commit into
Conversation
|
CI note: the code-related posture-gate and security-offline checks both pass. The only failing job is the Discord notification workflow; its log shows an empty DISCORD_WEBHOOK and exits before exercising this change. This is repository/fork-secret configuration rather than a patch failure. |
|
Nice work.
if all(not result["success"] for result in results["results"]):
raise HTTPException(500, f"Crawl request failed: {results['results'][0]['error_message']}")For a single-URL request "all failed" is just "it failed", so the detail gets logged and dropped by the same 500 branch. Stock That's the same body the issue reports for The detail is already interpolated here, so switching that |
|
Thanks for the concrete reproduction. You're right: the all-results-failed branch in /crawl also raises 500, so the issue's statement that /crawl is unaffected is too broad. This PR is scoped to the two single-URL handlers from #2116, and I don't want to expand it without maintainer direction. I'm happy to include that adjacent branch here if the maintainers prefer, or it can be tracked separately. |
|
That makes sense. |
Summary
Fixes #2116
Treat unsuccessful crawls from the single-URL
/mdand/llm/{url}handlers as upstream failures (502 Bad Gateway) so the existing exception handler preserveserror_messageinstead of replacing it with an opaque internal-server-error response. The LLM handler now also preserves deliberateHTTPExceptionstatuses.List of files changed and why
deploy/docker/api.py- centralize unsuccessful crawl handling and return a detail-preserving 502 from both single-URL handlers.deploy/docker/tests/test_api_crawl_failures.py- verify the 502 mapping, preserved anti-bot reason, both handler call sites, and LLM exception propagation.How Has This Been Tested?
.venv/bin/python -m pytest deploy/docker/tests/test_api_crawl_failures.py -q(3 passed).venv/bin/python -m pytest deploy/docker/tests/test_security_headers_xss.py::TestErrorSanitization -q(2 passed).venv/bin/python -m ruff check --select E9,F63,F7,F82 deploy/docker/api.py deploy/docker/tests/test_api_crawl_failures.py(passed)Checklist: