Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Improves error messages when web_fetch encounters HTTP 4xx/5xx responses:

  1. HTTP status code in error: Shows actual status code (e.g., HTTP 404) instead of generic HTTP error (4xx/5xx)

  2. Parsed error body: When the server returns an error page (like a 404), we now parse and include its content so the AI can understand what went wrong

  3. Cloudflare detection: Detects Cloudflare JS challenge pages and shows a clear error: Cloudflare security challenge (page requires JavaScript)

Example Outputs

Before:

Failed to fetch URL: HTTP error (4xx/5xx)

After:

HTTP 404
[parsed 404 page content shown]

Or for Cloudflare-protected sites:

HTTP 403: Cloudflare security challenge (page requires JavaScript)

Testing

  • Added test for HTTP 404 status code parsing
  • Added test for Cloudflare challenge detection

Generated with mux

- Parse and include HTTP status code (e.g., 'HTTP 404' instead of 'HTTP error 4xx/5xx')
- Include parsed error page content when available (e.g., 404 pages)
- Detect Cloudflare challenge pages and show clear error message
- Refactor response parsing into reusable helper functions
- Add tests for HTTP 404 handling and Cloudflare detection

_Generated with mux_
@ammario ammario merged commit d8710d7 into main Nov 25, 2025
13 checks passed
@ammario ammario deleted the web-fetch-error-body branch November 25, 2025 03:06
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