Skip to content

Enhancement: Detect Cloudflare/WAF blocks and surface actionable errors #79

Description

@virtualguard101

Summary

Some Notion API requests fail with HTTP 403 and a Cloudflare HTML body (Sorry, you have been blocked) instead of JSON. The sync logs the entire HTML as the error message, which is hard to diagnose and looks like a Notion permission failure.

Observed behavior

ERROR FAIL obsidian/Misc/HTML要点.md: 403 <!DOCTYPE html> ... Cloudflare ...
Your IP: 185.220.238.191

Other pages in the same run may succeed (e.g. CSS要点 updated OK) — intermittent WAF blocking, not missing Notion integration access.

Proposed solution

  1. In notion_request / error handling, detect Cloudflare/HTML 403 responses (content-type, body markers).
  2. Raise a short, actionable error, e.g.:
    • "Notion API blocked by Cloudflare (possible Tor/proxy IP). Retry from a different network or reduce request rate."
  3. Optionally extract Ray ID for support/debug.
  4. Consider limited retry with backoff for 403 HTML (may not help for hard blocks).

Acceptance criteria

  • Cloudflare 403 does not dump full HTML into logs.
  • Error message distinguishes WAF block vs Notion API JSON errors.
  • Existing retry logic unchanged for 429/502/503/504.

References

  • mkdocs_note/utils/notion/client.pynotion_request

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions