{"record":{"id":"0c7f8a402306176d","repo":"home-assistant/core","slug":"only-local-attachments-are-currently-supported","errorCode":null,"errorMessage":"Only local attachments are currently supported","messagePattern":"Only local attachments are currently supported","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/ai_task/task.py","lineNumber":84,"sourceCode":"\n            temp_filename = await hass.async_add_executor_job(\n                _save_camera_snapshot, image_data\n            )\n            created_files.append(temp_filename)\n\n            resolved_attachments.append(\n                conversation.Attachment(\n                    media_content_id=media_content_id,\n                    mime_type=image_data.content_type,\n                    path=temp_filename,\n                )\n            )\n            break\n        else:\n            # Handle regular media sources\n            media = await media_source.async_resolve_media(hass, media_content_id, None)\n            if media.path is None:\n                raise HomeAssistantError(\n                    \"Only local attachments are currently supported\"\n                )\n            resolved_attachments.append(\n                conversation.Attachment(\n                    media_content_id=media_content_id,\n                    mime_type=attachment.get(\"media_content_type\") or media.mime_type,\n                    path=media.path,\n                )\n            )\n\n    if not created_files:\n        return resolved_attachments\n\n    def cleanup_files() -> None:\n        \"\"\"Cleanup temporary files.\"\"\"\n        for file in created_files:\n            file.unlink(missing_ok=True)\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/ai_task/task.py#L66-L102","documentation":"HomeAssistantError raised in ai_task._resolve_attachments when media_source.async_resolve_media() resolves the attachment's media_content_id to an item whose .path is None — i.e. the media lives on a non-local source (URL-served, e.g. web media or a remote integration) rather than the local filesystem. The LLM API needs a real file path to upload, so non-local media is rejected explicitly.","triggerScenarios":"Calling ai_task.generate_image / generate_data with an attachments entry whose media_content_id points at a media source that serves content over HTTP(S) instead of a local path — media.path is then None and this error fires.","commonSituations":"Users attach media from URL-based sources (a camera snapshot served by URL, a web resource, or integrations that register URL-only media). The code above this branch already special-cases the ai_task local source; everything else must resolve to a path.","solutions":["Use a local media source for attachments: pass media_content_id values rooted at media-source://media/... or another source that exposes .path.","For remote images, download to a local file first (e.g. via downloader or a template that writes to /media) and attach the local copy.","For camera frames, use a snapshot written to disk rather than the streaming URL.","Check that the media directory is configured (see ai_task media source error) so local resolution succeeds."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async def attachment_is_local(hass, media_content_id: str) -> bool:\n    \"\"\"Resolve media up front; only path-backed sources can attach.\"\"\"\n    from homeassistant.components import media_source\n\n    media = await media_source.async_resolve_media(hass, media_content_id, None)\n    return media.path is not None","typeGuard":null,"tryCatchPattern":"from homeassistant.exceptions import HomeAssistantError\n\ntry:\n    resolved = await _resolve_attachments(hass, session, attachments)\nexcept HomeAssistantError as err:\n    # non-local media in the list: localize it, then retry\n    _LOGGER.warning(\"Attachment rejected (%s); download to /media first\", err)\n    raise","preventionTips":["Only attach media under media-source://media/... or other path-backed sources.","Download URL-based images to /media before attaching.","Use on-disk camera snapshots, not streaming URLs."],"tags":["homeassistant","ai-task","attachments","media-source"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}