{"record":{"id":"f97d2bd8863f7bb7","repo":"microsoft/autogen","slug":"error-while-getting-file-list","errorCode":null,"errorMessage":"Error while getting file list","messagePattern":"Error while getting file list","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py","lineNumber":301,"sourceCode":"            task = asyncio.create_task(\n                client.get(\n                    url,\n                    headers=headers,\n                )\n            )\n            cancellation_token.link_future(task)\n            try:\n                resp = await task\n                resp.raise_for_status()\n                data = await resp.json()\n            except asyncio.TimeoutError as e:\n                # e.add_note is only in py 3.11+\n                raise asyncio.TimeoutError(\"Timeout getting file list\") from e\n            except asyncio.CancelledError as e:\n                # e.add_note is only in py 3.11+\n                raise asyncio.CancelledError(\"File list retrieval cancelled\") from e\n            except aiohttp.ClientResponseError as e:\n                raise ConnectionError(\"Error while getting file list\") from e\n\n        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():","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py#L283-L319","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the original exception via `__cause__` (the aiohttp.ClientResponseError) to see the exact HTTP status and message","Call restart() to get a fresh session id and token, then retry","Ensure the executor's credential has the correct Azure Container Apps session role assignments and that the endpoint/resource id config is correct","Wrap file-list operations in retry logic with backoff for transient 5xx responses"],"exampleFix":"# after (diagnosing the hidden HTTP status)\ntry:\n    files = await executor.get_file_list(ct)\nexcept ConnectionError as e:\n    status = getattr(e.__cause__, \"status\", None)\n    if status in (401, 403):\n        await executor.restart()  # new token + session\n        files = await executor.get_file_list(ct)","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    files = await executor.get_file_list(ct)\nexcept ConnectionError as e:\n    status = getattr(e.__cause__, \"status\", None)\n    if status in (401, 403, 404):\n        await executor.restart()  # stale token/session -> new one\n        files = await executor.get_file_list(ct)\n    else:\n        raise","preventionTips":["Keep executor lifetimes short so access tokens never outlive their validity","Wrap all file operations with a helper that catches ConnectionError and inspects __cause__","restart() proactively before file operations on executors idle for many minutes"],"tags":["azure","network","http","files"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}