File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -256,15 +256,15 @@ async def query_endpoint_handler( # pylint: disable=R0914
256256
257257 if user_conversation is None :
258258 logger .warning (
259- "User %s attempted to query conversation %s they don't own" ,
260- user_id ,
259+ "Conversation %s not found for user %s" ,
261260 query_request .conversation_id ,
261+ user_id ,
262262 )
263263 raise HTTPException (
264- status_code = status .HTTP_403_FORBIDDEN ,
264+ status_code = status .HTTP_404_NOT_FOUND ,
265265 detail = {
266- "response" : "Access denied " ,
267- "cause" : "You do not have permission to access this conversation " ,
266+ "response" : "Conversation not found " ,
267+ "cause" : "The requested conversation does not exist. " ,
268268 },
269269 )
270270 else :
Original file line number Diff line number Diff line change @@ -2030,6 +2030,30 @@ async def test_get_topic_summary_system_prompt_retrieval(mocker):
20302030 mock_get_topic_summary_system_prompt .assert_called_once_with (mock_config )
20312031
20322032
2033+ @pytest .mark .asyncio
2034+ async def test_query_endpoint_handler_conversation_not_found (mocker , dummy_request ):
2035+ """Test that a 404 is raised for a non-existant conversation_id."""
2036+ mock_config = mocker .Mock ()
2037+ mocker .patch ("app.endpoints.query.configuration" , mock_config )
2038+
2039+ mocker .patch (
2040+ "app.endpoints.query.validate_conversation_ownership" , return_value = None
2041+ )
2042+
2043+ query_request = QueryRequest (
2044+ query = "What is OpenStack?" ,
2045+ conversation_id = "00000000-0000-0000-0000-000000000001" ,
2046+ )
2047+
2048+ with pytest .raises (HTTPException ) as exc_info :
2049+ await query_endpoint_handler (
2050+ request = dummy_request , query_request = query_request , auth = MOCK_AUTH
2051+ )
2052+
2053+ assert exc_info .value .status_code == status .HTTP_404_NOT_FOUND
2054+ assert "Conversation not found" in exc_info .value .detail ["response" ]
2055+
2056+
20332057@pytest .mark .asyncio
20342058async def test_get_topic_summary_agent_creation_parameters (mocker ):
20352059 """Test that get_topic_summary creates agent with correct parameters."""
You can’t perform that action at this time.
0 commit comments