Skip to content

Validate built-in transport kwargs#46546

Open
ahmedtaha100 wants to merge 2 commits intoAzure:mainfrom
ahmedtaha100:validate-built-in-transport-kwargs
Open

Validate built-in transport kwargs#46546
ahmedtaha100 wants to merge 2 commits intoAzure:mainfrom
ahmedtaha100:validate-built-in-transport-kwargs

Conversation

@ahmedtaha100
Copy link
Copy Markdown
Contributor

@ahmedtaha100 ahmedtaha100 commented Apr 26, 2026

Summary

This change fixes unsupported per-request keyword arguments leaking through built-in transports into the underlying HTTP libraries.

Previously, kwargs passed through Pipeline.run(...) or AsyncPipeline.run(...) could be forwarded unchanged into transports such as aiohttp, requests, trio-backed requests, or httpx. That could produce backend-specific failures, including the reported async aiohttp path where query_filter reached aiohttp.ClientSession.request(...).

The fix validates kwargs inside each built-in transport's send() method, after known supported transport options are consumed and before the backend HTTP client is called. If unsupported kwargs remain, the transport raises a clear Python-style TypeError, for example:

AioHttpTransport.send() got an unexpected keyword argument 'query_filter'

Custom transports are intentionally unchanged. Pipeline-level kwargs are still passed through to custom transport implementations, so third-party transports can continue accepting their own options.

Transports covered

  • azure-core: RequestsTransport, AioHttpTransport, AsyncioRequestsTransport, TrioRequestsTransport
  • corehttp: RequestsTransport, AioHttpTransport, HttpXTransport, AsyncHttpXTransport

Notes

  • Supported kwargs are consumed explicitly where each transport supports them.
  • aiohttp ssl and server_hostname request options are supported explicitly so custom token-binding/SNI transports can pass valid aiohttp options through.
  • Leftover unknown kwargs are rejected before reaching requests, aiohttp, or httpx.
  • corehttp httpx transports reject per-request connection_verify and connection_cert because httpx applies TLS configuration at client construction.
  • Both azure-core and corehttp CHANGELOGs document this under ### Breaking Changes.
  • Regression tests cover direct transport calls, pipeline-level calls, the original async failure path, aiohttp SSL/SNI passthrough, and custom transport passthrough.

Fixes #46365

Validation

  • PYTHONPATH=sdk/core/azure-core;sdk/core/corehttp;sdk/identity/azure-identity python -m pytest sdk/core/azure-core/tests/test_basic_transport.py sdk/core/azure-core/tests/async_tests/test_basic_transport_async.py sdk/core/azure-core/tests/test_pipeline.py -q
  • PYTHONPATH=sdk/core/azure-core;sdk/core/corehttp;sdk/identity/azure-identity python -m pytest sdk/core/corehttp/tests/test_transport.py sdk/core/corehttp/tests/async_tests/test_transport_async.py sdk/core/corehttp/tests/test_pipeline.py -q
  • PYTHONPATH=sdk/core/azure-core;sdk/core/corehttp;sdk/identity/azure-identity python -m pytest sdk/identity/azure-identity/tests/test_workload_identity_credential_async.py -q
  • python eng/tox/run_black.py -t sdk/core/azure-core
  • python eng/tox/run_black.py -t sdk/core/corehttp
  • python eng/tox/run_pylint.py -t sdk/core/azure-core
  • python eng/tox/run_pylint.py -t sdk/core/corehttp

SDK Contribution checklist

  • This pull request introduces an intentional breaking change, documented in both CHANGELOGs.
  • CHANGELOG is updated for both azure-core and corehttp.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Built-in transports now consume their supported per-request kwargs explicitly and raise TypeError on any leftover unknown kwargs before forwarding to the underlying HTTP library. Custom transports remain unaffected.

Fixes Azure#46365
@github-actions github-actions Bot added Azure.Core Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Apr 26, 2026
@github-actions
Copy link
Copy Markdown

Thank you for your contribution @ahmedtaha100! We will review the pull request and get back to you soon.

@ahmedtaha100
Copy link
Copy Markdown
Contributor Author

I looked through the current failing checks.

The red python - pullrequest status comes from the Windows build in build 6211631. The visible failure is in pipeline cleanup (Remove-Item on tags.json with an IOException), followed by downstream matrix/pool resolution failures. I don’t see a Python test failure there; the failure appears to happen before the test stages are prepared.

The red python - cosmos - ci status comes from build 6211629, specifically Test windows2022___EmulatorTestsPython310Standard. The failing test is tests/test_service_retry_policies.py::TestServiceRetryPolicies::test_service_response_retry_policy, where the retry counter was 1 instead of 3. This is in sdk/cosmos/azure-cosmos; the same job’s wheel run passed, and the other Cosmos variants passed.

I’m not planning to push a code change for these unless maintainers see something in the logs that points back to this PR.

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

Labels

Azure.Core Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azure-core: prevent unsupported per-call kwargs from leaking to built-in transports

1 participant