Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions portkey_ai/api_resources/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ def __init__(
)

self.allHeaders = self._build_headers(create_model_instance(Options))
if http_client:
http_client.base_url = (
http_client.base_url if http_client.base_url != "" else self.base_url
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison http_client.base_url != \"\" may not correctly handle all cases where base_url is unset. HTTPX's base_url is a URL object, not a string, and when unset it defaults to an empty URL object (which doesn't equal an empty string). Consider using if not http_client.base_url or str(http_client.base_url) == \"\" for a more robust check.

Suggested change
http_client.base_url if http_client.base_url != "" else self.base_url
http_client.base_url if http_client.base_url and str(http_client.base_url) != "" else self.base_url

Copilot uses AI. Check for mistakes.
)

self._client = http_client or httpx.Client(
base_url=self.base_url,
headers={
Expand Down Expand Up @@ -895,6 +900,10 @@ def __init__(
)

self.allHeaders = self._build_headers(create_model_instance(Options))
if http_client:
http_client.base_url = (
http_client.base_url if http_client.base_url != "" else self.base_url
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison http_client.base_url != \"\" may not correctly handle all cases where base_url is unset. HTTPX's base_url is a URL object, not a string, and when unset it defaults to an empty URL object (which doesn't equal an empty string). Consider using if not http_client.base_url or str(http_client.base_url) == \"\" for a more robust check.

Suggested change
http_client.base_url if http_client.base_url != "" else self.base_url
http_client.base_url if (http_client.base_url and str(http_client.base_url) != "") else self.base_url

Copilot uses AI. Check for mistakes.
)
self._client = http_client or AsyncHttpxClientWrapper(
base_url=self.base_url,
headers={
Expand Down