Skip to content

fix: use an async event hook for custom_domain in AsyncManagementClient - #907

Open
RaphaelFakhri wants to merge 1 commit into
auth0:masterfrom
RaphaelFakhri:fix/async-custom-domain-hook
Open

RaphaelFakhri wants to merge 1 commit into
auth0:masterfrom
RaphaelFakhri:fix/async-custom-domain-hook

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Changes

AsyncManagementClient registers _enforce_custom_domain_whitelist as a request event hook on an httpx.AsyncClient when custom_domain is set. httpx.AsyncClient awaits its hooks, and that function is synchronous, so every request fails with TypeError: object NoneType can't be used in 'await' expression.

This change adds _enforce_custom_domain_whitelist_async, a coroutine that calls the existing whitelist check, and registers it on the async client. ManagementClient keeps the sync hook.

  • Functions added: _enforce_custom_domain_whitelist_async (private)
  • Methods changed: AsyncManagementClient.__init__ (no signature change)
  • New tests send requests through httpx.MockTransport for both clients and check that the header is kept on /api/v2/users/{id} and removed on /api/v2/clients/{id}.

References

Testing

poetry run pytest tests/management/test_management_client.py -k request_enforces_whitelist: 2 passed. Without the source change, test_async_request_enforces_whitelist fails with the TypeError above. poetry run pytest: 724 passed, 4 skipped.

Not tested against a live tenant.

  • This change adds unit test coverage
  • This change adds integration test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner November 3, 2026 12:58

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncManagementClient with custom_domain fails every request with TypeError

1 participant