{"record":{"id":"e11d515a45c5bb95","repo":"ATH-MaaS/Pixelle-Video","slug":"file-path","errorCode":null,"errorMessage":"文件不存在: {file_path}","messagePattern":"文件不存在: (.+?)","errorType":"validation","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/image_processor.py","lineNumber":370,"sourceCode":"    \n    def upload(self, file_path: str) -> str:\n        \"\"\"\n        上传文件到阿里云OSS并获取URL（统一接口方法）\n        \n        Args:\n            file_path: 本地文件路径\n            \n        Returns:\n            oss_url: OSS URL，可在48小时内使用\n            \n        Raises:\n            FileNotFoundError: 文件不存在时\n            RuntimeError: API Key未设置时\n            Exception: 上传失败时\n        \"\"\"\n        # 检查文件是否存在\n        if not os.path.exists(file_path):\n            raise FileNotFoundError(f\"文件不存在: {file_path}\")\n        \n        if not self.api_key:\n            raise RuntimeError(\"DASHSCOPE_API_KEY 未设置，无法使用图片上传服务\")\n        \n        # 1. 获取上传凭证（注意：上传凭证接口有限流）\n        policy_data = self.get_upload_policy()\n        \n        # 2. 上传文件到OSS\n        oss_url = self.upload_file_to_oss(policy_data, file_path)\n        \n        # 3. 计算过期时间\n        expire_time = datetime.now() + timedelta(hours=48)\n        \n        logging.info(f\"文件上传成功: {file_path}\")\n        logging.info(f\"  OSS URL: {oss_url}\")\n        logging.info(f\"  过期时间: {expire_time.strftime('%Y-%m-%d %H:%M:%S')} (48小时)\")\n        \n        return oss_url","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/image_processor.py#L352-L388","documentation":"upload verifies the file exists on disk before starting the upload workflow (policy fetch → OSS upload → registration) and raises FileNotFoundError when os.path.exists(file_path) is false. Failing fast avoids wasted API calls for a nonexistent local file.","triggerScenarios":"Calling upload with a path that does not exist: typo'd path, file deleted/moved by an earlier pipeline step, relative path resolved from a different working directory, or a previous download step failed silently.","commonSituations":"Working directory differs between save and upload (relative paths break), image download failed earlier but the pipeline continued with a stale path, path built with wrong separators or case on Linux.","solutions":["Verify the file path exists (os.path.exists) before calling upload; fix the path or regenerate the file.","Use absolute paths (os.path.abspath) so a changing working directory cannot break resolution.","Check that the earlier step that was supposed to produce the file (e.g. download_image) actually succeeded.","Confirm the file was not moved/cleaned up by another process between creation and upload."],"exampleFix":"// before\nprocessor.upload(relative_path)  # depends on cwd\n\n// after\npath = os.path.abspath(relative_path)\nif not os.path.exists(path):\n    raise FileNotFoundError(f\"Cannot upload, missing file: {path}\")\nprocessor.upload(path)","handlingStrategy":"validation","validationCode":"import os\npath = os.path.abspath(file_path)\nif not os.path.exists(path):\n    raise FileNotFoundError(f\"File to upload does not exist: {path}\")\nif not os.path.isfile(path):\n    raise ValueError(f\"Path is not a file: {path}\")","typeGuard":"def is_existing_file(path) -> bool:\n    return isinstance(path, str) and os.path.isfile(path)","tryCatchPattern":"try:\n    url = processor.upload(file_path)\nexcept FileNotFoundError as e:\n    logging.error(f\"Upload aborted, file missing: {e}\")\n    # regenerate or re-download the file before retrying\n    raise","preventionTips":["Use absolute paths so changing working directories cannot break resolution","Confirm the producing step (download/split) succeeded before uploading","Validate file existence at pipeline stage boundaries","Avoid cleanup jobs removing files between creation and upload"],"tags":["file-not-found","upload","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}