{"record":{"id":"3e8802bb128d6ecf","repo":"langchain-ai/deepagents","slug":"media-file-does-not-exist-path","errorCode":null,"errorMessage":"media file does not exist: {path}","messagePattern":"media file does not exist: (.+?)","errorType":"exception","errorClass":"ChannelMediaError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/channels/base.py","lineNumber":266,"sourceCode":"\n    Returns:\n        The validated media payload.\n\n    Raises:\n        ChannelMediaError: If the file is missing, unsupported, or too large.\n    \"\"\"\n    try:\n        path = (\n            resolve_bounded_media_path(media.path, root, require_relative=False)\n            if root is not None\n            else media.path.expanduser()\n        )\n    except ValueError as exc:\n        msg = str(exc)\n        raise ChannelMediaError(msg) from exc\n    if not path.is_file():\n        msg = f\"media file does not exist: {path}\"\n        raise ChannelMediaError(msg)\n\n    detected = _media_type(path)\n    if detected != media.media_type:\n        msg = f\"media file type {detected!r} does not match requested type {media.media_type!r}\"\n        raise ChannelMediaError(msg)\n\n    return _validate_media_size(media, path=path, max_bytes=max_bytes)\n\n\ndef message_with_media_paths(\n    message: ChannelMessage,\n    *,\n    media_paths: Sequence[str],\n    mime_types: Sequence[str] = (),\n    has_media: bool | None = None,\n) -> ChannelMessage:\n    \"\"\"Return `message` with normalized inbound-media path metadata.\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/channels/base.py#L248-L284","documentation":"After resolving and validating the media path, `validate_media` checks `path.is_file()`. If the resolved path does not exist or is not a regular file, it raises `ChannelMediaError` with the resolved path in the message. This prevents sending nonexistent or special-file paths over a channel.","triggerScenarios":"Calling `validate_media`/`send_media` with a `ChannelMedia` whose `path` points to a file that does not exist, was deleted/moved before send, or is a directory/socket rather than a regular file.","commonSituations":"Generating a screenshot/PDF then sending before it is written; relative path resolved against the wrong working directory; typo in filename; temp file cleaned up by a prior step.","solutions":["Check `Path(media.path).is_file()` before calling and create/fix the file if missing.","Verify the working directory and that relative paths resolve under the expected root.","Catch `ChannelMediaError` and return a user-facing 'attachment not found' message."],"exampleFix":"# before\nawait channel.send_media(ChannelMedia(path=Path('out.png'), media_type='image'))\n\n# after\npath = Path('out.png')\nif not path.is_file():\n    raise FileNotFoundError(f'generate {path} before sending')\nawait channel.send_media(ChannelMedia(path=path, media_type='image'))","handlingStrategy":"validation","validationCode":"path = Path(media.path)\nif not path.is_file():\n    raise FileNotFoundError(f'media file missing before send: {path}')","typeGuard":"def is_readable_file(p: Path) -> bool:\n    try:\n        return p.is_file()\n    except OSError:\n        return False","tryCatchPattern":"try:\n    await channel.send_media(media)\nexcept ChannelMediaError as exc:\n    if 'does not exist' in str(exc):\n        await channel.send_text('Attachment is no longer available.')\n    else:\n        raise","preventionTips":["Generate and verify the artifact before composing the message.","Use absolute paths resolved against a known workspace.","Clean up temp files only after send completes (or send from a stable directory)."],"tags":["media","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}