microsoft/autogen · error · ConnectionError

Error while getting file list

Error message

Error while getting file list

What it means

Raised by AzureContainerCodeExecutor.get_file_list when the HTTP GET to the session's `files` endpoint returns a 4xx/5xx status (aiohttp's raise_for_status raises ClientResponseError, which is re-wrapped as ConnectionError). The file list is what powers upload/download coordination for the /mnt/data folder of the session.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py:301

            task = asyncio.create_task(
                client.get(
                    url,
                    headers=headers,
                )
            )
            cancellation_token.link_future(task)
            try:
                resp = await task
                resp.raise_for_status()
                data = await resp.json()
            except asyncio.TimeoutError as e:
                # e.add_note is only in py 3.11+
                raise asyncio.TimeoutError("Timeout getting file list") from e
            except asyncio.CancelledError as e:
                # e.add_note is only in py 3.11+
                raise asyncio.CancelledError("File list retrieval cancelled") from e
            except aiohttp.ClientResponseError as e:
                raise ConnectionError("Error while getting file list") from e

        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():

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Inspect the original exception via `__cause__` (the aiohttp.ClientResponseError) to see the exact HTTP status and message
  2. Call restart() to get a fresh session id and token, then retry
  3. Ensure the executor's credential has the correct Azure Container Apps session role assignments and that the endpoint/resource id config is correct
  4. Wrap file-list operations in retry logic with backoff for transient 5xx responses

Example fix

# after (diagnosing the hidden HTTP status)
try:
    files = await executor.get_file_list(ct)
except ConnectionError as e:
    status = getattr(e.__cause__, "status", None)
    if status in (401, 403):
        await executor.restart()  # new token + session
        files = await executor.get_file_list(ct)
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try:
    files = await executor.get_file_list(ct)
except ConnectionError as e:
    status = getattr(e.__cause__, "status", None)
    if status in (401, 403, 404):
        await executor.restart()  # stale token/session -> new one
        files = await executor.get_file_list(ct)
    else:
        raise

Prevention

When it happens

Trigger: Calling get_file_list directly, or download_files (which calls it internally), when the Azure Container Apps session endpoint responds with an error status: 401/403 from an expired or missing bearer token, 404 when the session id no longer exists (session timed out or was recycled), or 5xx from the service.

Common situations: Long-lived executor objects whose access token expired (tokens are short-lived; _ensure_access_token may not refresh in all states); calling get_file_list after the ACI session has been reclaimed due to idleness; wrong resource id / endpoint configuration so every call 404s.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/f97d2bd8863f7bb7. Report an issue: GitHub.