Skip to content

Commit

Permalink
Fixes init of cloud client when no profiles are set (#15160)
Browse files Browse the repository at this point in the history
  • Loading branch information
cicdw authored Aug 30, 2024
1 parent c73a41a commit 5f6f455
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/prefect/client/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 6 additions & 0 deletions tests/client/test_cloud_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5f6f455

Please sign in to comment.