Validate built-in transport kwargs#46546
Conversation
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
|
Thank you for your contribution @ahmedtaha100! We will review the pull request and get back to you soon. |
|
I looked through the current failing checks. The red The red I’m not planning to push a code change for these unless maintainers see something in the logs that points back to this PR. |
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(...)orAsyncPipeline.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 wherequery_filterreachedaiohttp.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-styleTypeError, 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
RequestsTransport,AioHttpTransport,AsyncioRequestsTransport,TrioRequestsTransportRequestsTransport,AioHttpTransport,HttpXTransport,AsyncHttpXTransportNotes
sslandserver_hostnamerequest options are supported explicitly so custom token-binding/SNI transports can pass valid aiohttp options through.connection_verifyandconnection_certbecause httpx applies TLS configuration at client construction.azure-coreandcorehttpCHANGELOGs document this under### Breaking Changes.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 -qPYTHONPATH=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 -qPYTHONPATH=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 -qpython eng/tox/run_black.py -t sdk/core/azure-corepython eng/tox/run_black.py -t sdk/core/corehttppython eng/tox/run_pylint.py -t sdk/core/azure-corepython eng/tox/run_pylint.py -t sdk/core/corehttpSDK Contribution checklist
azure-coreandcorehttp.General Guidelines and Best Practices
Testing Guidelines