{"record":{"id":"16346a102966c2d7","repo":"xtekky/gpt4free","slug":"lmarena-beta-encountered-an-error-hasarenaerror","errorCode":null,"errorMessage":"LMArena Beta encountered an error: hasArenaError","messagePattern":"LMArena Beta encountered an error: hasArenaError","errorType":"exception","errorClass":"ModelNotFoundError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/LMArena.py","lineNumber":659,"sourceCode":"                data[\"modelBMessageId\"] = modelBMessageId\n\n            yield JsonRequest.from_dict(data)\n            try:\n                async with StreamSession(**args, timeout=timeout or 5 * 60) as session:\n                    async with session.post(\n                        url,\n                        json=data,\n                        proxy=proxy,\n                    ) as response:\n                        await raise_for_status(response)\n                        args[\"cookies\"] = merge_cookies(args[\"cookies\"], response)\n                        async for chunk in response.iter_lines():\n                            line = chunk.decode()\n                            yield PlainTextResponse(line)\n                            if line.startswith(\"a0:\"):\n                                chunk = json.loads(line[3:])\n                                if chunk == \"hasArenaError\":\n                                    raise ModelNotFoundError(\n                                        \"LMArena Beta encountered an error: hasArenaError\"\n                                    )\n                                yield chunk\n                            elif line.startswith(\"b0:\"):\n                                ...\n                            elif line.startswith(\"ag:\"):\n                                chunk = json.loads(line[3:])\n                                yield Reasoning(chunk)\n                            elif (\n                                line.startswith(\"a2:\") or line.startswith(\"b2:\")\n                            ) and line == 'a2:[{\"type\":\"heartbeat\"}]':\n                                # 'a2:[{\"type\":\"heartbeat\"}]'\n                                continue\n                            elif line.startswith(\"a2:\"):\n                                chunk = json.loads(line[3:])\n                                __images = [\n                                    image.get(\"image\")\n                                    for image in chunk","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/LMArena.py#L641-L677","documentation":"While streaming the chat response from LMArena's Next.js flight protocol, a line prefixed 'a0:' carried the literal JSON string \"hasArenaError\". This is LMArena's own in-band error signal: the request reached the server and the stream started, but the arena backend rejected or failed the generation. g4f re-raises it as ModelNotFoundError.","triggerScenarios":"POSTing the conversation payload to LMArena succeeds, but during iter_lines() the model A stream ('a0:' prefix) yields the hasArenaError marker — e.g. when the selected model is temporarily disabled, the prompt triggers server-side moderation, or the arena service has an outage.","commonSituations":"A specific arena model being down or rate-limited server-side; prompts with content the arena refuses; using a model ID that exists in the catalog but is not currently servable; transient platform incidents.","solutions":["Retry with a different model from LMArena.get_models() — often only one arena model is affected","Retry the same request after a short wait; hasArenaError is frequently transient on the server side","Simplify the prompt/media payload if the error reproduces only for specific content","Check LMArena status/changelog and update g4f if the arena protocol changed"],"exampleFix":"// before\nresp = await client.chat.completions.create(model='arena/model-x', messages=msgs)\n\n// after\n# rotate models on failure\nfor model in ['arena/model-x', 'arena/model-y']:\n    try:\n        resp = await client.chat.completions.create(model=model, messages=msgs); break\n    except ModelNotFoundError: continue","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.errors import ModelNotFoundError\nfor model in candidate_models:\n    try:\n        resp = await client.chat.completions.create(model=model, messages=msgs)\n        break\n    except ModelNotFoundError as e:\n        if 'hasArenaError' in str(e):\n            continue  # this arena model is failing server-side; try next\n        raise","preventionTips":["Keep a list of fallback arena models","Retry once after a short delay — the error is often transient","Monitor repeated hasArenaError for a given model to detect deprecation"],"tags":["lmarena","streaming","server-error","transient"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}