{"record":{"id":"46cb9798e5cc9c89","repo":"yt-dlp/yt-dlp","slug":"received-invalid-json-data","errorCode":null,"errorMessage":"Received invalid JSON data","messagePattern":"Received invalid JSON data","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"yt_dlp/extractor/bigo.py","lineNumber":36,"sourceCode":"        'skip': 'livestream',\n    }, {\n        'url': 'https://www.bigo.tv/th/Tarlerm1304',\n        'only_matching': True,\n    }, {\n        'url': 'https://bigo.tv/115976881',\n        'only_matching': True,\n    }]\n\n    def _real_extract(self, url):\n        user_id = self._match_id(url)\n\n        info_raw = self._download_json(\n            'https://ta.bigo.tv/official_website/studio/getInternalStudioInfo',\n            user_id, data=urlencode_postdata({'siteId': user_id}),\n            headers={'Accept': 'application/json'})\n\n        if not isinstance(info_raw, dict):\n            raise ExtractorError('Received invalid JSON data')\n        if info_raw.get('code'):\n            raise ExtractorError(\n                'Bigo says: {} (code {})'.format(info_raw.get('msg'), info_raw.get('code')), expected=True)\n        info = info_raw.get('data') or {}\n\n        if not info.get('alive'):\n            raise UserNotLive(video_id=user_id)\n\n        formats, subs = self._extract_m3u8_formats_and_subtitles(\n            info.get('hls_src'), user_id, 'mp4', 'm3u8')\n\n        return {\n            'id': info.get('roomId') or user_id,\n            'title': info.get('roomTopic') or info.get('nick_name') or user_id,\n            'formats': formats,\n            'subtitles': subs,\n            'thumbnail': info.get('snapshot'),\n            'uploader': info.get('nick_name'),","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/yt-dlp/yt-dlp/blob/81ecd58b1394793e6da9998cc19fdb45657f1685/yt_dlp/extractor/bigo.py#L18-L54","documentation":"Raised by the Bigo extractor when the POST to ta.bigo.tv getInternalStudioInfo returns valid JSON that is not an object. _download_json already raises on unparseable bodies, so reaching this branch means the endpoint answered 200 with a JSON list, string, or number instead of the expected {code, msg, data} envelope — an API contract break rather than a transport error.","triggerScenarios":"The Bigo endpoint changing its response shape (e.g. returning an array or a bare string), or an edge/CDN node replying with a minimal JSON payload for unknown siteIds; anything where isinstance(info_raw, dict) is False.","commonSituations":"API version changes after a Bigo web update; hitting the internal endpoint with an unusual siteId that yields a degenerate response; old yt-dlp builds against the updated endpoint.","solutions":["Update yt-dlp to the latest version; response-shape changes get patched in the extractor.","Re-check the Bigo room URL — malformed ids can produce degenerate API replies.","If it persists, curl the endpoint with the same POST body and inspect the JSON type, then report upstream."],"exampleFix":"// before\ninfo_raw = self._download_json(url, user_id, ...)\nif not isinstance(info_raw, dict):\n    raise ExtractorError('Received invalid JSON data')\n// after (accept envelope wrapped in a list)\nif isinstance(info_raw, list) and len(info_raw) == 1 and isinstance(info_raw[0], dict):\n    info_raw = info_raw[0]","handlingStrategy":"type-guard","validationCode":"import json, urllib.request\n\ndef bigo_info_is_dict(site_id: str) -> bool:\n    req = urllib.request.Request(\n        'https://ta.bigo.tv/official_website/studio/getInternalStudioInfo',\n        data=urllib.parse.urlencode({'siteId': site_id}).encode(),\n        headers={'Accept': 'application/json'})\n    with urllib.request.urlopen(req, timeout=10) as r:\n        return isinstance(json.load(r), dict)","typeGuard":"def is_bigo_envelope(value) -> bool:\n    return isinstance(value, dict) and ('code' in value or 'data' in value)","tryCatchPattern":null,"preventionTips":["Check isinstance(response, dict) before reading code/msg/data","Pin a current yt-dlp; Bigo endpoint shape changes get patched upstream"],"tags":["bigo","json-api","response-shape","type-check","extractor"],"backgroundTag":"invalid-json-response","analyzedSha":"81ecd58b1394793e6da9998cc19fdb45657f1685","analyzedAt":"2026-08-22T12:21:25.439Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}