Skip to content

Commit 804688e

Browse files
committed
Remove the logic flaw in get_vector_store_ids
1 parent a9e0a01 commit 804688e

2 files changed

Lines changed: 7 additions & 24 deletions

File tree

src/utils/responses.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,11 @@
129129

130130
async def get_vector_store_ids(
131131
client: AsyncLlamaStackClient,
132-
vector_store_ids: Optional[list[str]] = None,
133132
) -> list[str]:
134-
"""Get vector store IDs for querying.
135-
136-
If vector_store_ids are provided, returns them. Otherwise fetches all
137-
available vector stores from Llama Stack.
133+
"""Fetche all available vector stores from Llama Stack.
138134
139135
Args:
140136
client: The AsyncLlamaStackClient to use for fetching stores
141-
vector_store_ids: Optional list of vector store IDs. If provided,
142-
returns this list. If None, fetches all available vector stores.
143137
144138
Returns:
145139
List of vector store IDs to query
@@ -148,9 +142,6 @@ async def get_vector_store_ids(
148142
HTTPException: With ServiceUnavailableResponse if connection fails,
149143
or InternalServerErrorResponse if API returns an error status
150144
"""
151-
if vector_store_ids is not None:
152-
return vector_store_ids
153-
154145
try:
155146
vector_stores = await client.vector_stores.list()
156147
return [vector_store.id for vector_store in vector_stores.data]

tests/unit/utils/test_responses.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,9 +2150,9 @@ async def test_prepare_responses_params_includes_mcp_provider_data_headers(
21502150

21512151
# The result should contain extra_headers with x-llamastack-provider-data
21522152
dumped = result.model_dump()
2153-
assert (
2154-
dumped["extra_headers"] is not None
2155-
), "extra_headers should not be None when MCP tools have headers"
2153+
assert dumped["extra_headers"] is not None, (
2154+
"extra_headers should not be None when MCP tools have headers"
2155+
)
21562156
assert "x-llamastack-provider-data" in dumped["extra_headers"]
21572157

21582158
provider_data = json.loads(
@@ -3148,14 +3148,6 @@ def test_multiple_stores_source_is_none(self, mocker: MockerFixture) -> None:
31483148
class TestGetVectorStoreIds:
31493149
"""Tests for get_vector_store_ids utility function."""
31503150

3151-
@pytest.mark.asyncio
3152-
async def test_returns_provided_ids_directly(self, mocker: MockerFixture) -> None:
3153-
"""Test that provided vector_store_ids are returned without fetching."""
3154-
client_mock = mocker.AsyncMock()
3155-
result = await get_vector_store_ids(client_mock, ["vs1", "vs2"])
3156-
assert result == ["vs1", "vs2"]
3157-
client_mock.vector_stores.list.assert_not_called()
3158-
31593151
@pytest.mark.asyncio
31603152
async def test_fetches_all_when_no_ids_provided(
31613153
self, mocker: MockerFixture
@@ -3172,7 +3164,7 @@ async def test_fetches_all_when_no_ids_provided(
31723164
client_mock = mocker.AsyncMock()
31733165
client_mock.vector_stores.list.return_value = mock_list_result
31743166

3175-
result = await get_vector_store_ids(client_mock, None)
3167+
result = await get_vector_store_ids(client_mock)
31763168
assert result == ["vs-fetched-1", "vs-fetched-2"]
31773169
client_mock.vector_stores.list.assert_called_once()
31783170

@@ -3185,7 +3177,7 @@ async def test_raises_on_connection_error(self, mocker: MockerFixture) -> None:
31853177
)
31863178

31873179
with pytest.raises(HTTPException) as exc_info:
3188-
await get_vector_store_ids(client_mock, None)
3180+
await get_vector_store_ids(client_mock)
31893181
assert exc_info.value.status_code == 503
31903182

31913183
@pytest.mark.asyncio
@@ -3202,7 +3194,7 @@ async def test_raises_on_api_status_error(self, mocker: MockerFixture) -> None:
32023194
)
32033195

32043196
with pytest.raises(HTTPException) as exc_info:
3205-
await get_vector_store_ids(client_mock, None)
3197+
await get_vector_store_ids(client_mock)
32063198
assert exc_info.value.status_code == 500
32073199

32083200

0 commit comments

Comments
 (0)