{"record":{"id":"9bf7657b686870fa","repo":"NanmiCoder/MediaCrawler","slug":"response-error","errorCode":null,"errorMessage":"response error","messagePattern":"response error","errorType":"exception","errorClass":"DataFetchError","httpStatus":null,"severity":"error","filePath":"media_platform/weibo/client.py","lineNumber":97,"sourceCode":"            response = await client.request(method, url, timeout=self.timeout, **kwargs)\n\n        if enable_return_response:\n            return response\n\n        try:\n            data: Dict = response.json()\n        except json.decoder.JSONDecodeError:\n            # issue: #771 Search API returns error 432, retry multiple times + update h5 cookies\n            utils.logger.error(f\"[WeiboClient.request] request {method}:{url} err code: {response.status_code} res:{response.text}\")\n            await self.playwright_page.goto(self._host)\n            await asyncio.sleep(2)\n            await self.update_cookies(browser_context=self.playwright_page.context)\n            raise DataFetchError(f\"get response code error: {response.status_code}\")\n\n        ok_code = data.get(\"ok\")\n        if ok_code == 0:  # response error\n            utils.logger.error(f\"[WeiboClient.request] request {method}:{url} err, res:{data}\")\n            raise DataFetchError(data.get(\"msg\", \"response error\"))\n        elif ok_code != 1:  # unknown error\n            utils.logger.error(f\"[WeiboClient.request] request {method}:{url} err, res:{data}\")\n            raise DataFetchError(data.get(\"msg\", \"unknown error\"))\n        else:  # response right\n            return data.get(\"data\", {})\n\n    async def get(self, uri: str, params=None, headers=None, **kwargs) -> Union[Response, Dict]:\n        final_uri = uri\n        if isinstance(params, dict):\n            final_uri = (f\"{uri}?\"\n                         f\"{urlencode(params)}\")\n\n        if headers is None:\n            headers = self.headers\n        return await self.request(method=\"GET\", url=f\"{self._host}{final_uri}\", headers=headers, **kwargs)\n\n    async def post(self, uri: str, data: dict) -> Dict:\n        json_str = json.dumps(data, separators=(',', ':'), ensure_ascii=False)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/weibo/client.py#L79-L115","documentation":"Raised as DataFetchError by WeiboClient.request (media_platform/weibo/client.py:97) when the parsed JSON body has ok == 0 — Weibo h5 API's explicit application-level error code. The message defaults to 'response error' when the response omits a 'msg' field; the actual data payload is logged just above. This is a business-logic rejection (bad params, invalid session, resource not found), distinct from transport failures.","triggerScenarios":"Any weibo client get/post where the JSON contains ok:0 — e.g. requesting a note/user that was deleted, malformed params, or a session whose cookies are valid transport-wise but rejected by the app layer. If the payload has no 'msg', the generic 'response error' text is used.","commonSituations":"Deleted/private weibo posts still in crawl queues; parameter changes after Weibo API updates; cookie sessions valid enough to get JSON but lacking required auth scopes.","solutions":["Check the logged res payload for Weibo's own msg describing the application error","Filter target ids (remove deleted/private notes) before requesting","Re-login if msg indicates session/auth problems","Handle per-item DataFetchError in the crawler loop so one bad note doesn't abort the batch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from media_platform.weibo.exception import DataFetchError\n\ntry:\n    data = await client.get(uri, params=params)\nexcept DataFetchError as e:\n    if str(e) in (\"response error\", \"unknown error\"):\n        log_and_skip(uri)  # app-level rejection (deleted note, bad params); don't abort batch\n        return None\n    raise","preventionTips":["Filter deleted/private note ids out of crawl queues before requesting","Catch DataFetchError per item so one rejection doesn't kill the batch","Read the logged res payload — Weibo's own msg names the real problem"],"tags":["weibo","api-error","json","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}