{"record":{"id":"2538c4407a05ac0f","repo":"NanmiCoder/MediaCrawler","slug":"note-not-found-or-abnormal-code-data-code","errorCode":null,"errorMessage":"Note not found or abnormal, code: {data['code']}","messagePattern":"Note not found or abnormal, code: (.+?)","errorType":"exception","errorClass":"NoteNotFoundError","httpStatus":null,"severity":"warning","filePath":"media_platform/xhs/client.py","lineNumber":193,"sourceCode":"            str(response_data.get(\"code\"))\n            if response_data is not None and response_data.get(\"code\") is not None\n            else \"\"\n        )\n        if response_code == str(self.IP_ERROR_CODE):\n            raise IPBlockError(self.IP_ERROR_STR)\n        if response_code == str(self.SECURITY_LIMIT_CODE):\n            raise PlatformAccessError(\n                f\"XHS account security restriction, code: {self.SECURITY_LIMIT_CODE}\"\n            )\n\n        if return_response:\n            return response.text\n        data: Dict = response_data if response_data is not None else response.json()\n        if data[\"success\"]:\n            return data.get(\"data\", data.get(\"success\", {}))\n        # IP_ERROR_CODE / SECURITY_LIMIT_CODE are already handled above, before return_response.\n        elif data[\"code\"] in (self.NOTE_NOT_FOUND_CODE, self.NOTE_ABNORMAL_CODE):\n            raise NoteNotFoundError(f\"Note not found or abnormal, code: {data['code']}\")\n        else:\n            err_msg = data.get(\"msg\", None) or f\"{response.text}\"\n            raise DataFetchError(err_msg)\n\n    @staticmethod\n    def _build_query_string(params: Dict) -> str:\n        \"\"\"Build URL query string with encoding matching browser behavior (commas not encoded)\"\"\"\n        parts = []\n        for key, value in params.items():\n            value_str = str(value) if value is not None else \"\"\n            parts.append(f\"{key}={quote(value_str, safe=',')}\")\n        return \"&\".join(parts)\n\n    async def get(self, uri: str, params: Optional[Dict] = None) -> Dict:\n        \"\"\"\n        GET request, signs request headers\n        Args:\n            uri: Request route","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/xhs/client.py#L175-L211","documentation":"NoteNotFoundError raised by XiaoHongShuClient.request when the response JSON's code equals -510000 (note not found) or -510001 (note abnormal/deleted). The endpoint answered successfully but reported the requested note is gone, so retrying the same note_id will not help.","triggerScenarios":"Calling get_note_by_id (or comment APIs) with a note_id that was deleted, set to private, or removed by moderation after it was discovered by search/creator crawling.","commonSituations":"Long crawls where search results contain notes deleted before their detail fetch; note links shared from other users whose authors later deleted them; xsec_token mismatch causing the API to treat the note as inaccessible.","solutions":["Treat as terminal for that note: catch NoteNotFoundError, log, and continue the crawl.","If it happens for every note, suspect an expired or wrong xsec_token being passed and re-fetch search results to get fresh tokens.","Filter note IDs by publish recency to avoid fetching already-removed content.","Do not retry the same note_id - these codes are deterministic."],"exampleFix":"// before\nnote = await xhs_client.get_note_by_id(note_id)\n// after\nfrom media_platform.xhs.exception import NoteNotFoundError\ntry:\n    note = await xhs_client.get_note_by_id(note_id)\nexcept NoteNotFoundError:\n    utils.logger.info(f\"note {note_id} gone, skipping\")\n    note = None","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from media_platform.xhs.exception import NoteNotFoundError\ntry:\n    note = await xhs_client.get_note_by_id(note_id)\nexcept NoteNotFoundError:\n    utils.logger.info(f\"note {note_id} deleted/abnormal - skipped\")\n    note = None","preventionTips":["Never retry on -510000/-510001 - the note is gone.","Pass fresh xsec_token values from current search results when fetching note details.","Prefer recently published notes to reduce mid-crawl deletions."],"tags":["xhs","note","not-found","data-fetch"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}