infiniflow/ragflow · error · RuntimeError
unexpected response content-type: {content_type or 'unknown'
Error message
unexpected response content-type: {content_type or 'unknown'}, response: {text[:200]} What it means
Error "unexpected response content-type: {content_type or 'unknown'}, response: {text[:200]}" thrown in infiniflow/ragflow.
Source
Thrown at api/channels/whatsapp/channel.py:129
path: str,
payload: dict[str, Any] | None = None,
) -> dict[str, Any]:
session = await self._ensure_http_session()
url = self._gateway_url(path)
async with session.request(
method,
url,
json=payload,
headers=self._gateway_headers(),
) as resp:
text = await resp.text()
if resp.status >= 400:
raise RuntimeError(f"status: {resp.status}, response: {text}")
if not text.strip():
return {}
content_type = resp.headers.get("content-type", "")
if "application/json" not in content_type.lower():
raise RuntimeError(f"unexpected response content-type: {content_type or 'unknown'}, response: {text[:200]}")
try:
return await resp.json()
except Exception as ex:
raise RuntimeError(f"invalid json response: {text[:200]}") from ex
async def _request_json_with_retry(
self,
method: str,
path: str,
payload: dict[str, Any] | None = None,
) -> dict[str, Any]:
deadline = time.time() + WHATSAPP_GATEWAY_START_RETRY_SECS
last_error: Exception | None = None
while time.time() < deadline and not self._stop_event.is_set():
try:
return await self._request_json(method, path, payload)
except (aiohttp.ClientError, asyncio.TimeoutError, OSError) as ex:
last_error = exView on GitHub (pinned to 554fb1133a)
Solutions
- Ensure the gateway returns application/json responses.
- Check for proxy or error pages returning HTML instead of JSON.
Example fix
content_type = resp.headers.get('content-type', '')
if 'application/json' not in content_type:
raise Exception(f'unexpected response content-type: {content_type}') When it happens
Trigger: Thrown at api/channels/whatsapp/channel.py:129 when the library encounters an invalid state.
Common situations: 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.
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/d1d532619bdb9404.
Report an issue: GitHub.