{"record":{"id":"e8e8beb494f0d25d","repo":"infiniflow/ragflow","slug":"invalid-json-response-text-200","errorCode":null,"errorMessage":"invalid json response: {text[:200]}","messagePattern":"invalid json response: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"api/channels/whatsapp/channel.py","lineNumber":133,"sourceCode":"        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\n                await asyncio.sleep(0.5)\n        if last_error is not None:\n            raise last_error\n        return await self._request_json(method, path, payload)","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/channels/whatsapp/channel.py#L115-L151","documentation":"Error \"invalid json response: {text[:200]}\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at api/channels/whatsapp/channel.py:133 when the library encounters an invalid state.","commonSituations":"The WhatsApp gateway returns malformed or truncated JSON; logging the raw body and validating the gateway build prevents this error.","solutions":["Check the raw gateway response body; it must be valid JSON.","Confirm the gateway version matches the expected API contract."],"exampleFix":"try:\n    data = json.loads(text)\nexcept json.JSONDecodeError:\n    raise Exception(f'invalid json response: {text[:200]}')","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-15T17:31:12.345Z"}