{"record":{"id":"6eaa050d41b8cc99","repo":"Fosowl/agenticSeek","slug":"cloudflare-protection-encountered-str-e","errorCode":null,"errorMessage":"Cloudflare protection encountered: {str(e)}","messagePattern":"Cloudflare protection encountered: (.+?)","errorType":"exception","errorClass":"CloudflareError","httpStatus":null,"severity":"error","filePath":"sources/llm_provider.py","lineNumber":502,"sourceCode":"            CloudflareError,\n            APIError\n        )\n        thought = \"\"\n        message = '\\n---\\n'.join([f\"{msg['role']}: {msg['content']}\" for msg in history])\n\n        try:\n            api = DeepSeekAPI(self.api_key)\n            chat_id = api.create_chat_session()\n            for chunk in api.chat_completion(chat_id, message):\n                if chunk['type'] == 'text':\n                    thought += chunk['content']\n            return thought\n        except AuthenticationError as e:\n            raise AuthenticationError(\"Authentication failed. Please check your token.\") from e\n        except RateLimitError as e:\n            raise RateLimitError(\"Rate limit exceeded. Please wait before making more requests.\") from e\n        except CloudflareError as e:\n            raise CloudflareError(f\"Cloudflare protection encountered: {str(e)}\") from e\n        except NetworkError as e:\n            raise NetworkError(\"Network error occurred. Check your internet connection.\") from e\n        except APIError as e:\n            raise APIError(f\"API error occurred: {str(e)}\") from e\n        return None\n\n    def litellm_fn(self, history, verbose=False):\n        \"\"\"\n        Use LiteLLM AI gateway for completion.\n        Routes to 100+ providers (OpenAI, Anthropic, Azure, Bedrock,\n        Vertex AI, Groq, Together, Ollama, etc.) based on model prefix.\n        See https://docs.litellm.ai/docs/providers\n        \"\"\"\n        try:\n            import litellm\n        except ImportError as e:\n            raise ImportError(\"litellm is not installed. Install with: pip install litellm\") from e\n","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/Fosowl/agenticSeek/blob/ae57a2357745a9706cb12d0fd76d954c84d166fa/sources/llm_provider.py#L484-L520","documentation":"dsk_deepseek wraps the unofficial dsk (deepseek4free) API's CloudflareError and re-raises it with a uniform message. The free DeepSeek endpoint sits behind Cloudflare bot protection, and when the challenge/solve fails the library raises CloudflareError, which this wrapper re-throws verbatim with its original message. It signals that the request never reached the model because Cloudflare blocked or challenged the client.","triggerScenarios":"Calling LLMProvider.dsk_deepseek(history) when the dsk library's Cloudflare bypass (token solving / user-agent handling) fails during DeepSeekAPI init, create_chat_session, or chat_completion — e.g. Cloudflare rotated its challenge or flagged the client IP.","commonSituations":"Running from datacenter/VPN IPs that Cloudflare distrusts; outdated dsk package after Cloudflare changed its challenge; heavy request volume triggering bot scoring; missing or stale cf_clearance cookies.","solutions":["Update the dsk package to the latest version (pip install -U dsk) since Cloudflare bypass logic breaks frequently","Retry later or from a different/residential network — the block is often IP-based","Switch to an official provider (e.g. litellm_fn or another backend in config.ini) instead of the free unofficial API","Check your DSK_DEEPSEEK_API_KEY setup; re-authenticate if the token session expired"],"exampleFix":"// before\nthought = provider.dsk_deepseek(history)\n// after\ntry:\n    thought = provider.dsk_deepseek(history)\nexcept CloudflareError:\n    thought = provider.litellm_fn(history)  # fallback to official gateway","handlingStrategy":"fallback","validationCode":"import dsk  # ensure installed and reasonably current\nassert provider.provider_key == 'dsk_deepseek' or True  # unofficial provider — expect instability","typeGuard":"def is_cloudflare_error(e: BaseException) -> bool:\n    return isinstance(e, CloudflareError) or 'Cloudflare' in str(e)","tryCatchPattern":"try:\n    thought = provider.dsk_deepseek(history)\nexcept CloudflareError as e:\n    logger.warning('Cloudflare block: %s', e)\n    thought = fallback_provider(history)  # e.g. litellm_fn","preventionTips":["Keep the dsk package updated — Cloudflare bypass code rots quickly","Avoid datacenter/VPN IPs when using the free endpoint","Always configure a second cloud provider as fallback in config.ini","Rate-limit your own calls to avoid bot scoring"],"tags":["cloudflare","anti-bot","unofficial-api","network"],"backgroundTag":"cloudflare-challenge-blocked","analyzedSha":"ae57a2357745a9706cb12d0fd76d954c84d166fa","analyzedAt":"2026-08-30T02:49:05.834Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}