Skip to content

fix(http): close the wrapped async transport - #734

Merged
Vincent Biret (baywet) merged 1 commit into
microsoft:mainfrom
rksharma-owg:fix/close-wrapped-async-transport
Sep 15, 2026
Merged

Vincent Biret (baywet) merged 1 commit into
microsoft:mainfrom
rksharma-owg:fix/close-wrapped-async-transport

Conversation

@rksharma-owg

Copy link
Copy Markdown
Contributor

Closing a client created by KiotaClientFactory currently leaves its underlying transport open. AsyncKiotaTransport inherits the no-op AsyncBaseTransport.aclose(), so both explicit client closure and async context exit stop at the wrapper.

Delegate aclose() to the wrapped transport. This restores the HTTPX client lifecycle contract without changing request processing or credential ownership. Cleanup exceptions propagate to the caller.

Validation on Python 3.13.14:

  • Five regression cases failed on upstream before the fix. They cover explicit closure, context exit, mounted transports, request exceptions, cancellation, repeated client closure, and cleanup errors using the real HTTPX client and Kiota factory.
  • pytest -q tests/test_kiota_client_factory.py: 15 passed.
  • pytest -q: 115 passed; upstream baseline was 110 passed.
  • yapf -dr kiota_http, mypy kiota_http, and git diff --check: passed. Mypy checked 24 source files.
  • pylint kiota_http --disable=W --rcfile=.pylintrc: exit 0, 10/10, with the existing unrecognized suggestion-mode option diagnostic.
  • CI's isort kiota_http: exit 0. A supplementary --check-only run identifies one existing blank-line issue in untouched redirect_handler_option.py, also reproduced from the upstream file. No unrelated formatting change is included; the changed implementation passes the import check.
  • uv build --wheel --out-dir <external-artifacts-directory>: passed.

Tests use in-memory transports and no live credentials or external HTTP service. Other Python versions and platforms were not run locally.

Closes #494.

Prepared with AI assistance; reproduction and validation ran locally.

@sonarqubecloud

Copy link
Copy Markdown

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues remain.

Pull request overview

Fixes async HTTPX transport cleanup by delegating aclose() to the wrapped transport.

Changes:

  • Added delegated async transport closure.
  • Added regression tests for lifecycle, errors, cancellation, mounts, and repeated closure.
File summaries
File Description
packages/http/httpx/tests/test_kiota_client_factory.py Verifies transport lifecycle behavior.
packages/http/httpx/kiota_http/middleware/async_kiota_transport.py Delegates asynchronous cleanup.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@baywet
Vincent Biret (baywet) merged commit 0590bc3 into microsoft:main Sep 15, 2026
52 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

[Bug] AsyncKiotaTransport does not cleanup resources correctly

3 participants