microsoft/autogen · error · ConnectionError
Error while downloading files
Error message
Error while downloading files
What it means
Raised by AzureContainerCodeExecutor.download_files when the GET to `files/content/{file}` returns an error HTTP status (ClientResponseError re-wrapped as ConnectionError). It occurs after the existence check passed, so it usually indicates an auth or transport problem rather than a missing file.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py:390
headers=headers,
)
)
cancellation_token.link_future(task)
try:
resp = await task
resp.raise_for_status()
local_path = self.work_dir / file
local_paths.append(str(local_path))
async with await open_file(local_path, "wb") as f:
await f.write(await resp.read())
except asyncio.TimeoutError as e:
# e.add_note is only in py 3.11+
raise asyncio.TimeoutError("Timeout downloading files") from e
except asyncio.CancelledError as e:
# e.add_note is only in py 3.11+
raise asyncio.CancelledError("Downloading files cancelled") from e
except aiohttp.ClientResponseError as e:
raise ConnectionError("Error while downloading files") from e
return local_paths
async def execute_code_blocks(
self, code_blocks: List[CodeBlock], cancellation_token: CancellationToken
) -> CodeResult:
"""(Experimental) Execute the code blocks and return the result.
Args:
code_blocks (List[CodeBlock]): The code blocks to execute.
cancellation_token (CancellationToken): a token to cancel the operation
input_files (Optional[Union[Path, str]]): Any files the code blocks will need to access
Returns:
CodeResult: The result of the code execution."""
self._ensure_access_token()
if self._available_packages is None:
await self._populate_available_packages(cancellation_token)View on GitHub (pinned to 027ecf0a37)
Solutions
- Inspect e.__cause__ for the HTTP status to distinguish auth (401/403) from transport issues
- Call restart() and re-run/re-download when the session was lost (note: restart clears remote files, so the producing code must re-run)
- Retry the download call: files remain on the service, so a retry after a transient failure succeeds
- Batch downloads smaller or persist artifacts elsewhere if files are very large
Defensive patterns
Strategy: retry
Validate before calling
null
Type guard
null
Try / catch
try:
paths = await executor.download_files(files, ct)
except ConnectionError:
await asyncio.sleep(1)
paths = await executor.download_files(files, ct) # files persist server-side; retry is safe Prevention
- Download outputs immediately after execution while the session is warm
- Group downloads to minimize the number of authenticated GETs
- Catch ConnectionError separately from FileNotFoundError: the former is transient, the latter means the file is absent
When it happens
Trigger: Downloading files when the bearer token expired between get_file_list and the content GET, when the session is reclaimed mid-download, or on 5xx from the Azure Container Apps sessions endpoint. A network failure part-way through downloading multiple files aborts the remaining files.
Common situations: Long download sequences of many generated artifacts outliving the access token validity; transient service errors; racing with session idle-timeout during large outputs.
Related errors
- Error while getting file list
- Error while uploading files
- {file} does not exist
- {logs_all}
- No stop reason found
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/5f34b6ac154da3ec.
Report an issue: GitHub.