xtekky/gpt4free · warning · RuntimeError
Response: {text}
Error message
Response: {text} What it means
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.
Source
Thrown at g4f/Provider/needs_auth/MetaAI.py:248
"x-fb-friendly-name": "AbraSearchPluginDialogQuery",
**headers,
}
async with self.session.post(
url, headers=headers, cookies=self.cookies, data=payload
) as response:
await raise_for_status(response, "Fetch sources failed")
text = await response.text()
if "<h1>Something Went Wrong</h1>" in text:
raise ResponseError("Response: Something Went Wrong")
try:
response_json = json.loads(text)
message = response_json["data"]["message"]
if message is not None:
searchResults = message["searchResults"]
if searchResults is not None:
return Sources(searchResults["references"])
except (KeyError, TypeError, json.JSONDecodeError):
raise RuntimeError(f"Response: {text}")
@staticmethod
def extract_value(text: str, key: str = None, start_str=None, end_str='",') -> str:
if start_str is None:
start_str = f'{key}":{{"value":"'
start = text.find(start_str)
if start >= 0:
start += len(start_str)
end = text.find(end_str, start)
if end >= 0:
return text[start:end]
def generate_offline_threading_id() -> str:
"""
Generates an offline threading ID.
Returns:View on GitHub (pinned to 973504e177)
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
Example fix
// before
# error escapes and kills the whole prompt
resp = await meta.prompt(query)
// after
# accept that sources may be unavailable
try:
resp = await meta.prompt(query)
except RuntimeError:
resp = await meta.prompt(query, stream=False) # or skip source-augmented mode Defensive patterns
Strategy: fallback
Try / catch
try:
resp = await meta.prompt(query)
except RuntimeError:
# sources parsing failed; completion may still be usable without sources
resp = await meta.prompt(query) if retry_enabled else degrade_to_no_sources() Prevention
- 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
When it happens
Trigger: 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.
Common situations: Meta changing the search plugin response schema; responses where message is null (no sources found); partial HTML bodies from proxies that break JSON parsing.
Related errors
- Invalid image element: {element}
- Response: Something Went Wrong
- \n".join([error.get("message") for error in json_line.get("e
- Meta AI isn't available yet in your country
- No images found
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/09fa90b55e9ae9e3.
Report an issue: GitHub.