fix(servicebus): Forward **kwargs to _build_pipeline in ServiceBusAdministrationClient#45719
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a kwargs-forwarding bug in ServiceBusAdministrationClient (sync + async) where __init__ did not pass user-provided **kwargs into _build_pipeline, preventing transport-layer options like connection_verify from being applied.
Changes:
- Forward
**kwargsfromServiceBusAdministrationClient.__init__to_build_pipelinein both sync and async management clients. - Add unit tests to validate that kwargs (including
connection_verifyand customtransport) are forwarded to_build_pipelinefor both sync and async clients.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py |
Passes **kwargs into _build_pipeline so transport/policy kwargs reach the sync pipeline/transport. |
sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_management_client_async.py |
Passes **kwargs into _build_pipeline so transport/policy kwargs reach the async pipeline/transport. |
sdk/servicebus/azure-servicebus/tests/test_mgmt_client_kwargs.py |
Adds regression tests verifying _build_pipeline receives forwarded kwargs for sync and async clients. |
You can also share your feedback on Copilot code review. Take the survey.
sdk/servicebus/azure-servicebus/tests/test_mgmt_client_kwargs.py
Outdated
Show resolved
Hide resolved
…lient (Azure#44999) - Pass **kwargs from __init__ to _build_pipeline() in both sync and async ServiceBusAdministrationClient so transport kwargs (connection_verify, transport, policies, ssl_context) reach the transport layer - Add unit tests verifying kwargs forwarding for both sync and async clients - Matches pattern from Azure#26015 fix for ServiceBusClient and azure-core base
1432aa8 to
3fa067a
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the Service Bus management (administration) clients where **kwargs provided to ServiceBusAdministrationClient.__init__ were not forwarded to _build_pipeline, preventing transport-related kwargs (e.g., connection_verify, transport, policies, ssl_context) from reaching the transport layer in both sync and async clients.
Changes:
- Forward
**kwargsfromServiceBusAdministrationClient.__init__to_build_pipeline(sync + async). - Add unit tests to assert kwargs forwarding behavior for
connection_verifyand customtransporton both sync and async clients.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py | Passes **kwargs into _build_pipeline so transport/policy kwargs are honored in the sync admin client. |
| sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_management_client_async.py | Passes **kwargs into _build_pipeline so transport/policy kwargs are honored in the async admin client. |
| sdk/servicebus/azure-servicebus/tests/test_mgmt_client_kwargs.py | Adds regression tests validating _build_pipeline receives forwarded kwargs (sync + async). |
You can also share your feedback on Copilot code review. Take the survey.
Fixes #44999
Problem
ServiceBusAdministrationClient.__init__callsself._build_pipeline()without forwarding**kwargs. This means kwargs likeconnection_verify,transport,policies, andssl_contextnever reach the transport layer.Both the sync and async management clients are affected. The
_build_pipelinemethod correctly accepts and uses**kwargs— for example,AioHttpTransport(**kwargs)on the async side andRequestsTransport(**kwargs)on the sync side — but since__init__never passes them, the transport is always constructed with empty kwargs.The reporter observed this on the async client with
connection_verifyon Ubuntu containers whereaiohttpuses the system OpenSSL CA store. The sync client has the same code path but the symptom is masked becauserequestsdefaults tocertifi's CA bundle.Fix
Forward
**kwargsfrom__init__to_build_pipeline()in both sync and asyncServiceBusAdministrationClient:This matches:
azure-corebase pattern:AsyncPipelineClientandPipelineClientboth callself._build_pipeline(self._config, **kwargs)ServiceBusClientdoes not respect theconnection_verifyparameter #26015 forServiceBusClient(identical bug, fixed in 2022 — the management client was not included in that fix)Testing
Added 4 unit tests in
tests/test_mgmt_client_kwargs.py:test_sync_build_pipeline_receives_kwargs— verifiesconnection_verifyreaches_build_pipelinetest_sync_build_pipeline_receives_custom_transport— verifies customtransportkwarg reaches_build_pipelinetest_async_build_pipeline_receives_kwargs— async equivalenttest_async_build_pipeline_receives_custom_transport— async equivalentAll tests use
unittest.mock.patchto verify kwargs forwarding without requiring live resources.