Skip to content

fix(servicebus): Forward **kwargs to _build_pipeline in ServiceBusAdministrationClient#45719

Open
EldertGrootenboer wants to merge 1 commit intoAzure:mainfrom
EldertGrootenboer:fix/servicebus-admin-kwargs-44999
Open

fix(servicebus): Forward **kwargs to _build_pipeline in ServiceBusAdministrationClient#45719
EldertGrootenboer wants to merge 1 commit intoAzure:mainfrom
EldertGrootenboer:fix/servicebus-admin-kwargs-44999

Conversation

@EldertGrootenboer
Copy link

Fixes #44999

Problem

ServiceBusAdministrationClient.__init__ calls self._build_pipeline() without forwarding **kwargs. This means kwargs like connection_verify, transport, policies, and ssl_context never reach the transport layer.

Both the sync and async management clients are affected. The _build_pipeline method correctly accepts and uses **kwargs — for example, AioHttpTransport(**kwargs) on the async side and RequestsTransport(**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_verify on Ubuntu containers where aiohttp uses the system OpenSSL CA store. The sync client has the same code path but the symptom is masked because requests defaults to certifi's CA bundle.

Fix

Forward **kwargs from __init__ to _build_pipeline() in both sync and async ServiceBusAdministrationClient:

# Before
self._pipeline = self._build_pipeline()

# After
self._pipeline = self._build_pipeline(**kwargs)

This matches:

Testing

Added 4 unit tests in tests/test_mgmt_client_kwargs.py:

  • test_sync_build_pipeline_receives_kwargs — verifies connection_verify reaches _build_pipeline
  • test_sync_build_pipeline_receives_custom_transport — verifies custom transport kwarg reaches _build_pipeline
  • test_async_build_pipeline_receives_kwargs — async equivalent
  • test_async_build_pipeline_receives_custom_transport — async equivalent

All tests use unittest.mock.patch to verify kwargs forwarding without requiring live resources.

Copilot AI review requested due to automatic review settings March 16, 2026 16:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 **kwargs from ServiceBusAdministrationClient.__init__ to _build_pipeline in both sync and async management clients.
  • Add unit tests to validate that kwargs (including connection_verify and custom transport) are forwarded to _build_pipeline for 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.

…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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 **kwargs from ServiceBusAdministrationClient.__init__ to _build_pipeline (sync + async).
  • Add unit tests to assert kwargs forwarding behavior for connection_verify and custom transport on 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.

@EldertGrootenboer EldertGrootenboer enabled auto-merge (squash) March 16, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async ServiceBusAdministrationClient is not using connection_verify kwargs to build pipeline transport

3 participants