AsyncManagementClient with custom_domain fails every request with TypeError

未關閉 適合新手
#906 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

@RaphaelFakhri 已經在處理了。

開始於 2026年11月3日。

  • #907 來自 @RaphaelFakhri —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
api, backend

研究方向

從AsyncManagementClient.__init__開始,檢查_enforce_custom_domain_whitelist如何註冊到httpx.AsyncClient的請求鉤子中;並與同步版ManagementClient的行為比較。使用提供的httpx.MockTransport範例重現,接著確認請求成功,且Auth0-Custom-Domain在允許清單中的路徑上保留,在其他路徑上移除。

由索引模型根據 Issue 內容生成。

描述

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

主要語言
Python
星號
578
分支
191
平均合併
2 天 20 小時
30 天內合併 PR
4

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

auth0/auth0-python 的其他 Issue

查看 auth0/auth0-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。