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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Optional, cast

import httpx
from httpx import HTTPStatusError

from phoenix.client.__generated__ import v1
from phoenix.client.types.prompts import PromptVersion
Expand Down Expand Up @@ -90,6 +91,7 @@ def get(
PromptVersion: The retrieved prompt version data.

Raises:
ValueError: If prompt identifier or prompt version id is not found.
httpx.HTTPStatusError: If the HTTP request returned an unsuccessful status code.

Example::
Expand All @@ -111,9 +113,14 @@ def get(
)
"""
url = _url(prompt_version_id, prompt_identifier, tag)
response = self._client.get(url)
response.raise_for_status()
return PromptVersion._loads(cast(v1.GetPromptResponseBody, response.json())["data"]) # pyright: ignore[reportPrivateUsage]
try:
prompt_response = self._client.get(url)
prompt_response.raise_for_status()
except HTTPStatusError as e:
if e.response.status_code == 404:
raise ValueError(f"Prompt not found: {prompt_identifier or prompt_version_id}")
Copy link

Choose a reason for hiding this comment

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

Bug: Error Message Mismatch in URL Lookup

The ValueError message for 404 responses in the get methods uses prompt_identifier or prompt_version_id. This expression's priority conflicts with the URL construction logic, which prioritizes prompt_version_id when both are provided. This results in misleading error messages, referencing the identifier that wasn't actually used for the lookup.

Additional Locations (1)

Fix in Cursor Fix in Web

raise
return PromptVersion._loads(cast(v1.GetPromptResponseBody, prompt_response.json())["data"]) # pyright: ignore[reportPrivateUsage]

def create(
self,
Expand Down Expand Up @@ -355,6 +362,7 @@ async def get(
PromptVersion: The retrieved prompt version data.

Raises:
ValueError: If prompt identifier or prompt version id is not found.
httpx.HTTPStatusError: If the HTTP request returned an unsuccessful status code.

Example::
Expand All @@ -376,9 +384,14 @@ async def get(
)
"""
url = _url(prompt_version_id, prompt_identifier, tag)
response = await self._client.get(url)
response.raise_for_status()
return PromptVersion._loads(cast(v1.GetPromptResponseBody, response.json())["data"]) # pyright: ignore[reportPrivateUsage]
try:
prompt_response = await self._client.get(url)
prompt_response.raise_for_status()
except HTTPStatusError as e:
if e.response.status_code == 404:
raise ValueError(f"Prompt not found: {prompt_identifier or prompt_version_id}")
raise
return PromptVersion._loads(cast(v1.GetPromptResponseBody, prompt_response.json())["data"]) # pyright: ignore[reportPrivateUsage]

async def create(
self,
Expand Down
Loading