diff --git a/src/prefect/client/cloud.py b/src/prefect/client/cloud.py index 101a7b3dc98c..ba5d4df3477b 100644 --- a/src/prefect/client/cloud.py +++ b/src/prefect/client/cloud.py @@ -73,9 +73,10 @@ def __init__( **httpx_settings, enable_csrf_support=False ) + api_url = prefect.settings.PREFECT_API_URL.value() or "" if match := ( re.search(PARSE_API_URL_REGEX, host) - or re.search(PARSE_API_URL_REGEX, prefect.settings.PREFECT_API_URL.value()) + or re.search(PARSE_API_URL_REGEX, api_url) ): self.account_id, self.workspace_id = match.groups() diff --git a/tests/client/test_cloud_client.py b/tests/client/test_cloud_client.py index 2a7841d52c46..3fa2d4fe5d8c 100644 --- a/tests/client/test_cloud_client.py +++ b/tests/client/test_cloud_client.py @@ -45,6 +45,12 @@ async def mock_work_pool_types(): yield +async def test_cloud_client_init_with_no_api(): + with temporary_settings({PREFECT_API_URL: None}): + async with get_cloud_client() as client: + assert client + + async def test_cloud_client_follow_redirects(): httpx_settings = {"follow_redirects": True} async with get_cloud_client(httpx_settings=httpx_settings) as client: