{"record":{"id":"9719ac88a5a317d3","repo":"microsoft/autogen","slug":"file-does-not-exist","errorCode":null,"errorMessage":"{file} does not exist","messagePattern":"(.+?) does not exist","errorType":"validation","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py","lineNumber":321,"sourceCode":"        values = data[\"value\"]\n        file_info_list: List[str] = []\n        for value in values:\n            file = value[\"properties\"]\n            file_info_list.append(file[\"filename\"])\n        return file_info_list\n\n    async def upload_files(self, files: List[Union[Path, str]], cancellation_token: CancellationToken) -> None:\n        self._ensure_access_token()\n        # TODO: Better to use the client auth system rather than headers\n        headers = {\"Authorization\": f\"Bearer {self._access_token}\"}\n        url = self._construct_url(\"files/upload\")\n        timeout = aiohttp.ClientTimeout(total=float(self._timeout))\n        async with aiohttp.ClientSession(timeout=timeout) as client:\n            for file in files:\n                file_path = self.work_dir / file\n                if not file_path.is_file():\n                    # TODO: what to do here?\n                    raise FileNotFoundError(f\"{file} does not exist\")\n\n                data = aiohttp.FormData()\n                async with await open_file(file_path, \"rb\") as f:\n                    data.add_field(\n                        \"file\",\n                        f,\n                        filename=os.path.basename(file_path),\n                        content_type=\"application/octet-stream\",\n                    )\n\n                    task = asyncio.create_task(\n                        client.post(\n                            url,\n                            headers=headers,\n                            data=data,\n                        )\n                    )\n","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py#L303-L339","documentation":"Raised by AzureContainerCodeExecutor.upload_files when one of the requested files does not exist as a file under the executor's local work_dir. The method joins each name to self.work_dir and checks is_file() before POSTing to the session's files/upload endpoint.","triggerScenarios":"Calling upload_files([\"data.csv\"]) when data.csv is not in the executor's work_dir, when the path is a directory, or when a relative subdirectory component does not exist locally. Any missing entry aborts the whole upload loop mid-way.","commonSituations":"Passing a bare filename when the file lives elsewhere (user forgot to set work_dir or copied the file into a different directory); passing an absolute path where work_dir/file then double-qualifies; uploading after the file was written by a previous container run that never saved it locally.","solutions":["Ensure the file exists under executor.work_dir before calling: create/copy it there first","If the file lives elsewhere, configure the executor with the correct work_dir at construction, or copy the file into executor.work_dir","Check for typos and that the path is a file (not a directory) via Path.is_file()"],"exampleFix":"# before\nawait executor.upload_files([\"data.csv\"], ct)  # FileNotFoundError if not in work_dir\n\n# after\nsrc = Path(\"/elsewhere/data.csv\")\nshutil.copy(src, executor.work_dir / src.name)\nawait executor.upload_files([src.name], ct)","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef ensure_uploadable(executor, names: list[str]) -> None:\n    for name in names:\n        p = Path(executor.work_dir) / name\n        if not p.is_file():\n            raise FileNotFoundError(f\"copy {name} into {executor.work_dir} before upload\")","typeGuard":"null","tryCatchPattern":"try:\n    await executor.upload_files(files, ct)\nexcept FileNotFoundError as e:\n    missing = Path(str(e).split()[0].strip('\"'))\n    shutil.copy(source_dir / missing.name, executor.work_dir / missing.name)\n    await executor.upload_files(files, ct)","preventionTips":["Stage all files into executor.work_dir before calling upload_files","Derive upload names from actual directory listings, not hardcoded strings"],"tags":["azure","files","validation","upload"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}