AsyncManagementClient with custom_domain fails every request with TypeError
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in AsyncManagementClient.__init__ and inspect how _enforce_custom_domain_whitelist is registered in the httpx.AsyncClient request hooks; compare with the sync ManagementClient behavior. Reproduce with the provided httpx.MockTransport example, then verify requests succeed and Auth0-Custom-Domain is kept on whitelisted paths and removed on other paths.
Written by the indexing model from the issue text.
Description
Description
When you create AsyncManagementClient with custom_domain, every request raises:
TypeError: object NoneType can't be used in 'await' expression
AsyncManagementClient.__init__ adds _enforce_custom_domain_whitelist to the request event hooks of an httpx.AsyncClient. That function is synchronous. httpx.AsyncClient awaits each request hook (await hook(request)), so awaiting the None it returns raises TypeError before the request is sent. The sync ManagementClient is not affected.
Reproduction
import asyncio
import httpx
from auth0.management import AsyncManagementClient
async def main():
client = AsyncManagementClient(
domain="tenant.auth0.com",
token="TOKEN",
custom_domain="login.example.com",
httpx_client=httpx.AsyncClient(
transport=httpx.MockTransport(lambda r: httpx.Response(200, json={}))
),
)
await client.users.get("auth0|abc123")
asyncio.run(main())
The same error occurs without httpx_client, since the SDK then creates its own httpx.AsyncClient and adds the same hook.
Additional context
Expected: the request is sent, with the Auth0-Custom-Domain header kept on whitelisted paths and removed on other paths, as with ManagementClient.
httpx 0.28.1. Custom domain support was added in #799.
auth0-python version
6.8.0
Python version
3.12
- Dominant language
- Python
- Stars
- 578
- Forks
- 191
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/auth0-python
-
SyntaxWarning: invalid escape sequence '\(' in auth0/management/types/client_metadata.py (6.8.0)Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
auth0/auth0-python#908 · 1 comment ·
-
pushed_authorization_request sends list authorization_details as a Python reprPossibly taken @RaphaelFakhri claimed this 32 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
auth0/auth0-python#903 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
auth0/auth0-python#852 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
auth0/auth0-python#856 · 4 comments · 1 reaction ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
auth0/auth0-python#789 · 1 comment · 1 reaction ·
All issues in auth0/auth0-python
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 89/100
Maintainers usually reply within 1 day
-
DoRA magnitude vectors are not loaded by Transformers load_adapter / from_pretrained(adapter_dir)Openpost-v1
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
huggingface/peft#4208 · 1 comment ·
Maintainers usually reply within 1 day
-
approved correction metadata
Difficulty 1/5 Under an hour Newbie friendliness 76/100
acl-org/acl-anthology#10996 · 2 comments ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
gke-labs/kube-agents#6620 ·
Maintainers usually reply within 1 day