{"record":{"id":"09fa90b55e9ae9e3","repo":"xtekky/gpt4free","slug":"response-text","errorCode":null,"errorMessage":"Response: {text}","messagePattern":"Response: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"g4f/Provider/needs_auth/MetaAI.py","lineNumber":248,"sourceCode":"            \"x-fb-friendly-name\": \"AbraSearchPluginDialogQuery\",\n            **headers,\n        }\n        async with self.session.post(\n            url, headers=headers, cookies=self.cookies, data=payload\n        ) as response:\n            await raise_for_status(response, \"Fetch sources failed\")\n            text = await response.text()\n            if \"<h1>Something Went Wrong</h1>\" in text:\n                raise ResponseError(\"Response: Something Went Wrong\")\n            try:\n                response_json = json.loads(text)\n                message = response_json[\"data\"][\"message\"]\n                if message is not None:\n                    searchResults = message[\"searchResults\"]\n                    if searchResults is not None:\n                        return Sources(searchResults[\"references\"])\n            except (KeyError, TypeError, json.JSONDecodeError):\n                raise RuntimeError(f\"Response: {text}\")\n\n    @staticmethod\n    def extract_value(text: str, key: str = None, start_str=None, end_str='\",') -> str:\n        if start_str is None:\n            start_str = f'{key}\":{{\"value\":\"'\n        start = text.find(start_str)\n        if start >= 0:\n            start += len(start_str)\n            end = text.find(end_str, start)\n            if end >= 0:\n                return text[start:end]\n\n\ndef generate_offline_threading_id() -> str:\n    \"\"\"\n    Generates an offline threading ID.\n\n    Returns:","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/MetaAI.py#L230-L266","documentation":"In fetch_sources(), parsing of the sources response failed with KeyError, TypeError, or json.JSONDecodeError while walking response_json['data']['message']['searchResults']['references'] (as written, the f-string lacks braces so the literal expression is the message — the effective text is 'Response: <raw body>'). It means the endpoint answered non-error HTML but the body did not match the expected GraphQL shape.","triggerScenarios":"POSTing AbraSearchPluginDialogQuery returns a 200 body that is not valid JSON, or JSON lacking data/message/searchResults keys — e.g. empty search results shape changes, auth-token drift, or an interstitial page without the error h1 marker.","commonSituations":"Meta changing the search plugin response schema; responses where message is null (no sources found); partial HTML bodies from proxies that break JSON parsing.","solutions":["Log the raw text included in the message to see the actual body returned","Refresh cookies/tokens via update_cookies() and retry once","Treat sources as optional and consume the completion without them when parsing fails","Update g4f to pick up any schema changes in fetch_sources"],"exampleFix":"// before\n# error escapes and kills the whole prompt\nresp = await meta.prompt(query)\n\n// after\n# accept that sources may be unavailable\ntry:\n    resp = await meta.prompt(query)\nexcept RuntimeError:\n    resp = await meta.prompt(query, stream=False)  # or skip source-augmented mode","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = await meta.prompt(query)\nexcept RuntimeError:\n    # sources parsing failed; completion may still be usable without sources\n    resp = await meta.prompt(query) if retry_enabled else degrade_to_no_sources()","preventionTips":["Wrap source-augmented prompts separately from plain completions","Log raw response text on parse failure to detect schema changes early","Update g4f when Meta alters the search plugin response shape"],"tags":["metaai","parsing","sources","schema-change"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}