{"record":{"id":"c3fd7022de81d79c","repo":"mem0ai/mem0","slug":"error-while-downloading-image-url","errorCode":null,"errorMessage":"Error while downloading {image_url}.","messagePattern":"Error while downloading (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mem0/memory/utils.py","lineNumber":219,"sourceCode":"                ]\n                if not text_parts:\n                    continue\n                returned_messages.append({\"role\": role, \"content\": \" \".join(text_parts)})\n            else:\n                description = get_image_description(msg, llm, vision_details)\n                returned_messages.append({\"role\": role, \"content\": description})\n        elif isinstance(content, dict) and content.get(\"type\") == \"image_url\":\n            if llm is None:\n                continue\n            image_url_obj = content.get(\"image_url\")\n            image_url = image_url_obj.get(\"url\") if isinstance(image_url_obj, dict) else None\n            if not image_url:\n                raise ValueError(\"image_url content part is missing image_url.url\")\n            try:\n                description = get_image_description(image_url, llm, vision_details)\n                returned_messages.append({\"role\": role, \"content\": description})\n            except Exception as e:\n                raise Exception(f\"Error while downloading {image_url}.\") from e\n        else:\n            # Regular text content\n            returned_messages.append(msg)\n\n    return returned_messages\n\n\ndef process_telemetry_filters(filters):\n    \"\"\"\n    Process the telemetry filters\n    \"\"\"\n    if filters is None:\n        return [], {}\n\n    encoded_ids = {}\n    if \"user_id\" in filters:\n        encoded_ids[\"user_id\"] = hashlib.md5(filters[\"user_id\"].encode()).hexdigest()\n    if \"agent_id\" in filters:","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/memory/utils.py#L201-L237","documentation":"Raised when get_image_description() throws while processing a valid-looking image_url part; mem0 wraps the original exception with 'Error while downloading {image_url}.' and chains it via `from e`. Despite the wording, the root cause (inspect e.__cause__) can be anything in the describe pipeline: an unreachable URL, a 403/404, an unsupported image format, a timeout, or a vision-LLM API failure — not only a download problem.","triggerScenarios":"Passing an expired/signed S3 URL, a URL behind auth (403), a 404, or a URL unreachable from the server's network; passing a data: URI the vision provider rejects; vision LLM quota/API-key errors surfacing during description generation; slow hosts timing out during download.","commonSituations":"Pre-signed upload URLs that expired before the memory call; intranet image URLs used from a container without network access; free-tier vision API keys exhausted; oversized images rejected by the provider.","solutions":["Fetch the URL yourself first (curl/requests) from the same machine to confirm reachability and status code","Inspect the chained exception (except Exception as e: print(e.__cause__)) to see whether it is download vs vision-LLM failure","Use long-lived accessible URLs or base64 data URIs; re-upload the image to storage you control","If it is the vision LLM failing, verify that model's API key, quota, and that the configured model supports vision"],"exampleFix":"# before\nawait memory.add([{\"role\": \"user\", \"content\": [{\"type\": \"image_url\", \"image_url\": {\"url\": signed_url}}]}], user_id=\"alice\")\n\n# after\nimport requests\nassert requests.head(signed_url, timeout=10).status_code == 200, \"URL expired; re-sign it\"\nawait memory.add([{\"role\": \"user\", \"content\": [{\"type\": \"image_url\", \"image_url\": {\"url\": signed_url}}]}], user_id=\"alice\")","handlingStrategy":"try-catch","validationCode":"import requests\ndef url_ok(u, timeout=10) -> bool:\n    try:\n        return requests.head(u, timeout=timeout, allow_redirects=True).status_code < 400\n    except requests.RequestException:\n        return False\n# skip or re-fetch images failing this check before memory.add()","typeGuard":null,"tryCatchPattern":"try:\n    await memory.add(messages, user_id=uid)\nexcept Exception as e:\n    if \"Error while downloading\" in str(e) and e.__cause__ is not None:\n        logger.warning(\"image pipeline failed: %r\", e.__cause__)\n        # retry with the offending image part stripped, or with a fresh URL\n    else:\n        raise","preventionTips":["Pre-check image URLs (status + auth) from the same network as the mem0 process","Use long-lived URLs or data URIs you control","Log e.__cause__ — the wrapper message hides the real failure","Keep vision-LLM keys and quotas healthy; the wrap also covers provider errors"],"tags":["multimodal","vision","network","image-download","exception-chaining"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}