Skip to content

fix(api): return 403 for anti-bot blocked results in /md and /llm endpoints - #2185

Open
Battleplus wants to merge 1 commit into
unclecode:mainfrom
Battleplus:fix/2116-md-llm-error-codes
Open

fix(api): return 403 for anti-bot blocked results in /md and /llm endpoints#2185
Battleplus wants to merge 1 commit into
unclecode:mainfrom
Battleplus:fix/2116-md-llm-error-codes

Conversation

@Battleplus

Copy link
Copy Markdown

Summary

Both handle_markdown_request and handle_llm_qa in deploy/docker/api.py promoted any unsuccessful crawl into HTTP 500. Since 0.8.5, is_blocked() sets success=False with error_message = "Blocked by anti-bot protection: <reason>", so Cloudflare-protected sites returned opaque 500 instead of a client-meaningful error.

This PR differentiates anti-bot failures (403) from genuine server errors (500) by inspecting the error message for blocked / anti-bot keywords.

Changes

  • deploy/docker/api.py: In both handle_markdown_request and handle_llm_qa, check result.error_message for anti-bot keywords before deciding status code.

Test plan

  • POST /md with a Cloudflare-protected URL → should return 403 with "Blocked by anti-bot protection" detail
  • POST /llm/{url} with a Cloudflare-protected URL → should return 403
  • POST /md with a genuinely broken URL → should still return 500

Fixes #2116

…points

Both handle_markdown_request and handle_llm_qa promoted any unsuccessful
crawl into HTTP 500. Since 0.8.5, is_blocked() sets success=False with
error_message 'Blocked by anti-bot protection: <reason>', so Cloudflare-
protected sites returned opaque 500 instead of a client-meaningful error.

Differentiate anti-bot failures (403) from genuine server errors (500)
by inspecting the error message for 'blocked' / 'anti-bot' keywords.

Fixes unclecode#2116

Signed-off-by: Battleplus <3559424769@qq.com>
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.

[Bug]: /md and /llm/{url} return HTTP 500 when anti-bot detection marks a result failed

1 participant