microsoft/autogen · error · FileNotFoundError
{file} does not exist
Error message
{file} does not exist What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py:321
values = data["value"]
file_info_list: List[str] = []
for value in values:
file = value["properties"]
file_info_list.append(file["filename"])
return file_info_list
async def upload_files(self, files: List[Union[Path, str]], cancellation_token: CancellationToken) -> None:
self._ensure_access_token()
# TODO: Better to use the client auth system rather than headers
headers = {"Authorization": f"Bearer {self._access_token}"}
url = self._construct_url("files/upload")
timeout = aiohttp.ClientTimeout(total=float(self._timeout))
async with aiohttp.ClientSession(timeout=timeout) as client:
for file in files:
file_path = self.work_dir / file
if not file_path.is_file():
# TODO: what to do here?
raise FileNotFoundError(f"{file} does not exist")
data = aiohttp.FormData()
async with await open_file(file_path, "rb") as f:
data.add_field(
"file",
f,
filename=os.path.basename(file_path),
content_type="application/octet-stream",
)
task = asyncio.create_task(
client.post(
url,
headers=headers,
data=data,
)
)
View on GitHub (pinned to 027ecf0a37)
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()
Example fix
# before
await executor.upload_files(["data.csv"], ct) # FileNotFoundError if not in work_dir
# after
src = Path("/elsewhere/data.csv")
shutil.copy(src, executor.work_dir / src.name)
await executor.upload_files([src.name], ct) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def ensure_uploadable(executor, names: list[str]) -> None:
for name in names:
p = Path(executor.work_dir) / name
if not p.is_file():
raise FileNotFoundError(f"copy {name} into {executor.work_dir} before upload") Type guard
null
Try / catch
try:
await executor.upload_files(files, ct)
except FileNotFoundError as e:
missing = Path(str(e).split()[0].strip('"'))
shutil.copy(source_dir / missing.name, executor.work_dir / missing.name)
await executor.upload_files(files, ct) Prevention
- Stage all files into executor.work_dir before calling upload_files
- Derive upload names from actual directory listings, not hardcoded strings
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error while uploading files
- Timeout must be greater than or equal to 1.
- Error while getting file list
- Error while downloading files
- Invalid configuration: {str(e)}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/9719ac88a5a317d3.
Report an issue: GitHub.