Skip to content

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

Open
RKS (rksharma-owg) wants to merge 1 commit into
microsoft:mainfrom
rksharma-owg:fix/close-wrapped-async-transport
Open

RKS (rksharma-owg) wants to merge 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Bug] AsyncKiotaTransport does not cleanup resources correctly

1 participant