{"record":{"id":"d1d532619bdb9404","repo":"infiniflow/ragflow","slug":"unexpected-response-content-type-content-type-or","errorCode":null,"errorMessage":"unexpected response content-type: {content_type or 'unknown'}, response: {text[:200]}","messagePattern":"unexpected response content-type: (.+?), response: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"api/channels/whatsapp/channel.py","lineNumber":129,"sourceCode":"        path: str,\n        payload: dict[str, Any] | None = None,\n    ) -> dict[str, Any]:\n        session = await self._ensure_http_session()\n        url = self._gateway_url(path)\n        async with session.request(\n            method,\n            url,\n            json=payload,\n            headers=self._gateway_headers(),\n        ) as resp:\n            text = await resp.text()\n            if resp.status >= 400:\n                raise RuntimeError(f\"status: {resp.status}, response: {text}\")\n            if not text.strip():\n                return {}\n            content_type = resp.headers.get(\"content-type\", \"\")\n            if \"application/json\" not in content_type.lower():\n                raise RuntimeError(f\"unexpected response content-type: {content_type or 'unknown'}, response: {text[:200]}\")\n            try:\n                return await resp.json()\n            except Exception as ex:\n                raise RuntimeError(f\"invalid json response: {text[:200]}\") from ex\n\n    async def _request_json_with_retry(\n        self,\n        method: str,\n        path: str,\n        payload: dict[str, Any] | None = None,\n    ) -> dict[str, Any]:\n        deadline = time.time() + WHATSAPP_GATEWAY_START_RETRY_SECS\n        last_error: Exception | None = None\n        while time.time() < deadline and not self._stop_event.is_set():\n            try:\n                return await self._request_json(method, path, payload)\n            except (aiohttp.ClientError, asyncio.TimeoutError, OSError) as ex:\n                last_error = ex","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/channels/whatsapp/channel.py#L111-L147","documentation":"Error \"unexpected response content-type: {content_type or 'unknown'}, response: {text[:200]}\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at api/channels/whatsapp/channel.py:129 when the library encounters an invalid state.","commonSituations":"The gateway or an intermediate proxy responds with HTML or plain text (e.g. an error page) instead of JSON; verifying the gateway endpoint prevents this error.","solutions":["Ensure the gateway returns application/json responses.","Check for proxy or error pages returning HTML instead of JSON."],"exampleFix":"content_type = resp.headers.get('content-type', '')\nif 'application/json' not in content_type:\n    raise Exception(f'unexpected response content-type: {content_type}')","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}