{"record":{"id":"80f8400608938f40","repo":"xtekky/gpt4free","slug":"failed-to-get-download-url","errorCode":null,"errorMessage":"Failed to get download URL","messagePattern":"Failed to get download URL","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/LMArena.py","lineNumber":516,"sourceCode":"                ) as response:\n                    await raise_for_status(response)\n                async with session.post(\n                    url=cls.url,\n                    json=[key],\n                    headers={\n                        \"accept\": \"text/x-component\",\n                        \"content-type\": \"text/plain;charset=UTF-8\",\n                        \"next-action\": cls._next_actions[\"getSignedUrl\"],\n                        \"referer\": cls.url,\n                    },\n                ) as response:\n                    await raise_for_status(response)\n                    text = await response.text()\n                    line = next(\n                        filter(lambda x: x.startswith(\"1:\"), text.split(\"\\n\")), \"\"\n                    )\n                    if not line:\n                        raise Exception(\"Failed to get download URL\")\n\n                    chunk = json.loads(line[2:])\n                    if not chunk.get(\"success\"):\n                        raise Exception(\"Failed to get download URL\")\n                    image_url = chunk.get(\"data\", {}).get(\"url\")\n                    uploaded_file = {\n                        \"name\": key,\n                        \"contentType\": file_type,\n                        \"url\": image_url,\n                    }\n                debug.log(f\"Uploaded image to: {image_url}\")\n                ImagesCache[image_hash] = uploaded_file\n                files.append(uploaded_file)\n        return files\n\n    @classmethod\n    def read_args(cls, args: dict = {}):\n        cache_file = cls.get_cache_file()","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/LMArena.py#L498-L534","documentation":"Raised inside LMArena's image upload helper after a POST to the getSignedUrl Next.js server action. The response body is expected to contain a line prefixed '1:' whose JSON payload carries {success: true, data: {url: ...}}. This instance fires when that payload has success set to false, i.e. the server processed the action but refused to issue a signed download URL.","triggerScenarios":"Calling LMArena with media/image attachments: upload_files() POSTs to cls.url with header next-action = cls._next_actions['getSignedUrl']; the returned '1:' line parses as JSON with success != true (e.g. {'success': false}).","commonSituations":"The Next.js server-action ID changed after an LMArena deploy (stale _next_actions mapping), an expired or Cloudflare-challenged session still returning 200 HTML/JSON, or an image type/size the signed-URL endpoint rejects.","solutions":["Refresh authentication: delete the LMArena cache/args file and let get_args_from_nodriver re-create cookies (or pass lmarena_args), then retry","Update g4f to the latest version so cls._next_actions server-action IDs match the current LMArena build","Inspect debug logs (debug.log) for the raw response text to confirm whether the '1:' payload is success:false or an HTML Cloudflare challenge page","Reduce media payload: use a common content type (image/jpeg, image/png) and smaller file size"],"exampleFix":"// before\nresp = await client.chat.completions.create(model='...', messages=[...], media=[open('heic.img','rb')])\n\n// after\n# refresh auth + use a standard image type\nimg = Image.open('photo.heic').convert('RGB'); img.save('/tmp/photo.jpg', 'JPEG')\nresp = await client.chat.completions.create(model='...', messages=[...], media=[open('/tmp/photo.jpg','rb')])","handlingStrategy":"retry","validationCode":"from g4f.Provider.needs_auth.LMArena import LMArena\nargs = LMArena.read_args()\nif not args:\n    raise SystemExit('Authenticate LMArena first (no cached args)')","typeGuard":"def lmarena_has_auth(args) -> bool:\n    return bool(args) and isinstance(args, dict) and bool(args.get('cookies'))","tryCatchPattern":"try:\n    resp = await client.chat.completions.create(model=..., messages=msgs, media=[img])\nexcept Exception as e:\n    if 'Failed to get download URL' in str(e):\n        # refresh auth once, then retry with a standard image type\n        await refresh_lmarena_auth()\n        resp = await client.chat.completions.create(model=..., messages=msgs, media=[converted_img])\n    else:\n        raise","preventionTips":["Authenticate once via nodriver so cached args exist before using media","Convert images to JPEG/PNG before upload","Keep g4f updated — LMArena server-action IDs change with deploys"],"tags":["lmarena","image-upload","auth","server-action"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}