{"record":{"id":"235e06c1fc703322","repo":"FujiwaraChoki/MoneyPrinterV2","slug":"media-file-does-not-exist-file-path","errorCode":null,"errorMessage":"Media file does not exist: {file_path}","messagePattern":"Media file does not exist: (.+?)","errorType":"error_code","errorClass":"PostBridgeClientError","httpStatus":null,"severity":"error","filePath":"src/classes/PostBridge.py","lineNumber":99,"sourceCode":"            accounts.extend(page_accounts)\n\n            meta = response_json.get(\"meta\", {})\n            url = meta.get(\"next\") if isinstance(meta, dict) else None\n\n        return accounts\n\n    def upload_media(self, file_path: str) -> str:\n        \"\"\"\n        Upload a local media file to Post Bridge and return its media ID.\n\n        Args:\n            file_path (str): Absolute path to a local media file.\n\n        Returns:\n            media_id (str): Uploaded media ID.\n        \"\"\"\n        if not os.path.exists(file_path):\n            raise PostBridgeClientError(f\"Media file does not exist: {file_path}\")\n\n        file_name = os.path.basename(file_path)\n        mime_type = self._guess_mime_type(file_path)\n        file_size = os.path.getsize(file_path)\n\n        upload_response = self._request_json(\n            \"POST\",\n            f\"{self.API_BASE}/media/create-upload-url\",\n            json={\n                \"name\": file_name,\n                \"mime_type\": mime_type,\n                \"size_bytes\": file_size,\n            },\n        )\n\n        media_id = upload_response.get(\"media_id\")\n        upload_url = upload_response.get(\"upload_url\")\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/FujiwaraChoki/MoneyPrinterV2/blob/5192af8eca97759f941834b947e3ceb209da0649/src/classes/PostBridge.py#L81-L117","documentation":"Raised by PostBridgeClient.upload_media when the local media file path does not exist before attempting the upload handshake. The client fails fast rather than sending a bogus request to the API.","triggerScenarios":"Calling maybe_crosspost_youtube_short with a video path that was moved/deleted after generation, a relative path resolved from a different cwd, or a typo in the configured output path.","commonSituations":"Temp files cleaned up between generation and crosspost, paths from config.json pointing at another machine's layout, or the render step failing silently so the file was never produced.","solutions":["Check the render/download step actually produced the file before crossposting","Use absolute, resolved paths (Path(...).resolve()) when passing file_path","If the file was deleted, regenerate it or fix the stale path in config"],"exampleFix":"// before\nclient.upload_media(\"output/short.mp4\")\n\n// after\nfrom pathlib import Path\np = Path(\"output/short.mp4\").resolve()\nif not p.is_file():\n    raise FileNotFoundError(f\"Render output missing: {p}\")\nclient.upload_media(str(p))","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(file_path).expanduser().resolve()\nif not p.is_file():\n    raise FileNotFoundError(f\"Media file missing before upload: {p}\")\nclient.upload_media(str(p))","typeGuard":"from pathlib import Path\n\ndef is_uploadable_media_file(p: str) -> bool:\n    try:\n        return Path(p).is_file() and Path(p).stat().st_size > 0\n    except OSError:\n        return False","tryCatchPattern":"try:\n    client.upload_media(file_path)\nexcept PostBridgeClientError as exc:\n    if \"Media file does not exist\" in str(exc):\n        regenerate_media_and_retry(file_path)\n    else:\n        raise","preventionTips":["Pass absolute resolved paths to upload_media","Verify the render step succeeded before starting the crosspost flow","Keep generated media in a stable directory that isn't cleaned by tmp janitors"],"tags":["python","api-client","filesystem","upload"],"backgroundTag":"path-not-found","analyzedSha":"5192af8eca97759f941834b947e3ceb209da0649","analyzedAt":"2026-08-28T10:31:46.474Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}