Skip to content

Commit 3e15433

Browse files
committed
Make tests and schema in line with query auth errors
1 parent dc792e9 commit 3e15433

File tree

6 files changed

+131
-135
lines changed

6 files changed

+131
-135
lines changed

docs/openapi.json

Lines changed: 122 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@
324324
"query"
325325
],
326326
"summary": "Query Endpoint Handler",
327-
"description": "Handle request to the /query endpoint.\n\nProcesses a POST request to the /query endpoint, forwarding the\nuser's query to a selected Llama Stack LLM or agent and\nreturning the generated response.\n\nValidates configuration and authentication, selects the appropriate model\nand provider, retrieves the LLM response, updates metrics, and optionally\nstores a transcript of the interaction. Handles connection errors to the\nLlama Stack service by returning an HTTP 500 error.\n\nReturns:\n QueryResponse: Contains the conversation ID and the LLM-generated response.",
327+
"description": "Handle request to the /query endpoint using Agent API.\n\nThis is a wrapper around query_endpoint_handler_base that provides\nthe Agent API specific retrieve_response and get_topic_summary functions.\n\nReturns:\n QueryResponse: Contains the conversation ID and the LLM-generated response.",
328328
"operationId": "query_endpoint_handler_v1_query_post",
329329
"requestBody": {
330330
"content": {
@@ -355,7 +355,7 @@
355355
}
356356
]
357357
},
358-
"400": {
358+
"401": {
359359
"description": "Missing or invalid credentials provided by client",
360360
"content": {
361361
"application/json": {
@@ -375,6 +375,9 @@
375375
}
376376
}
377377
},
378+
"404": {
379+
"description": "Requested model or provider not found"
380+
},
378381
"500": {
379382
"description": "Internal Server Error",
380383
"detail": {
@@ -631,7 +634,7 @@
631634
"operationId": "feedback_status_v1_feedback_status_get",
632635
"responses": {
633636
"200": {
634-
"description": "Successful Response",
637+
"description": "Feedback status successfully retrieved",
635638
"content": {
636639
"application/json": {
637640
"schema": {
@@ -661,7 +664,7 @@
661664
},
662665
"responses": {
663666
"200": {
664-
"description": "Successful Response",
667+
"description": "Feedback status successfully updated",
665668
"content": {
666669
"application/json": {
667670
"schema": {
@@ -670,6 +673,36 @@
670673
}
671674
}
672675
},
676+
"400": {
677+
"description": "Missing or invalid credentials provided by client",
678+
"content": {
679+
"application/json": {
680+
"schema": {
681+
"$ref": "#/components/schemas/UnauthorizedResponse"
682+
}
683+
}
684+
}
685+
},
686+
"401": {
687+
"description": "Missing or invalid credentials provided by client",
688+
"content": {
689+
"application/json": {
690+
"schema": {
691+
"$ref": "#/components/schemas/UnauthorizedResponse"
692+
}
693+
}
694+
}
695+
},
696+
"403": {
697+
"description": "Client does not have permission to access resource",
698+
"content": {
699+
"application/json": {
700+
"schema": {
701+
"$ref": "#/components/schemas/ForbiddenResponse"
702+
}
703+
}
704+
}
705+
},
673706
"422": {
674707
"description": "Validation Error",
675708
"content": {
@@ -1179,6 +1212,83 @@
11791212
}
11801213
}
11811214
},
1215+
"/v2/query": {
1216+
"post": {
1217+
"tags": [
1218+
"query_v2"
1219+
],
1220+
"summary": "Query Endpoint Handler V2",
1221+
"description": "Handle request to the /query endpoint using Responses API.\n\nThis is a wrapper around query_endpoint_handler_base that provides\nthe Responses API specific retrieve_response and get_topic_summary functions.\n\nReturns:\n QueryResponse: Contains the conversation ID and the LLM-generated response.",
1222+
"operationId": "query_endpoint_handler_v2_v2_query_post",
1223+
"requestBody": {
1224+
"content": {
1225+
"application/json": {
1226+
"schema": {
1227+
"$ref": "#/components/schemas/QueryRequest"
1228+
}
1229+
}
1230+
},
1231+
"required": true
1232+
},
1233+
"responses": {
1234+
"200": {
1235+
"description": "Successful Response",
1236+
"content": {
1237+
"application/json": {
1238+
"schema": {
1239+
"$ref": "#/components/schemas/QueryResponse"
1240+
}
1241+
}
1242+
},
1243+
"conversation_id": "123e4567-e89b-12d3-a456-426614174000",
1244+
"response": "LLM answer",
1245+
"referenced_documents": [
1246+
{
1247+
"doc_url": "https://docs.openshift.com/container-platform/4.15/operators/olm/index.html",
1248+
"doc_title": "Operator Lifecycle Manager (OLM)"
1249+
}
1250+
]
1251+
},
1252+
"400": {
1253+
"description": "Missing or invalid credentials provided by client",
1254+
"content": {
1255+
"application/json": {
1256+
"schema": {
1257+
"$ref": "#/components/schemas/UnauthorizedResponse"
1258+
}
1259+
}
1260+
}
1261+
},
1262+
"403": {
1263+
"description": "User is not authorized",
1264+
"content": {
1265+
"application/json": {
1266+
"schema": {
1267+
"$ref": "#/components/schemas/ForbiddenResponse"
1268+
}
1269+
}
1270+
}
1271+
},
1272+
"500": {
1273+
"description": "Internal Server Error",
1274+
"detail": {
1275+
"response": "Unable to connect to Llama Stack",
1276+
"cause": "Connection error."
1277+
}
1278+
},
1279+
"422": {
1280+
"description": "Validation Error",
1281+
"content": {
1282+
"application/json": {
1283+
"schema": {
1284+
"$ref": "#/components/schemas/HTTPValidationError"
1285+
}
1286+
}
1287+
}
1288+
}
1289+
}
1290+
}
1291+
},
11821292
"/readiness": {
11831293
"get": {
11841294
"tags": [
@@ -1436,7 +1546,7 @@
14361546
}
14371547
]
14381548
},
1439-
"AuthenticationConfiguration-Input": {
1549+
"AuthenticationConfiguration": {
14401550
"properties": {
14411551
"module": {
14421552
"type": "string",
@@ -1476,7 +1586,7 @@
14761586
"jwk_config": {
14771587
"anyOf": [
14781588
{
1479-
"$ref": "#/components/schemas/JwkConfiguration-Input"
1589+
"$ref": "#/components/schemas/JwkConfiguration"
14801590
},
14811591
{
14821592
"type": "null"
@@ -1489,75 +1599,7 @@
14891599
"title": "AuthenticationConfiguration",
14901600
"description": "Authentication configuration."
14911601
},
1492-
"AuthenticationConfiguration-Output": {
1493-
"properties": {
1494-
"module": {
1495-
"type": "string",
1496-
"title": "Module",
1497-
"default": "noop"
1498-
},
1499-
"skip_tls_verification": {
1500-
"type": "boolean",
1501-
"title": "Skip Tls Verification",
1502-
"default": false
1503-
},
1504-
"k8s_cluster_api": {
1505-
"anyOf": [
1506-
{
1507-
"type": "string",
1508-
"minLength": 1,
1509-
"format": "uri"
1510-
},
1511-
{
1512-
"type": "null"
1513-
}
1514-
],
1515-
"title": "K8S Cluster Api"
1516-
},
1517-
"k8s_ca_cert_path": {
1518-
"anyOf": [
1519-
{
1520-
"type": "string",
1521-
"format": "file-path"
1522-
},
1523-
{
1524-
"type": "null"
1525-
}
1526-
],
1527-
"title": "K8S Ca Cert Path"
1528-
},
1529-
"jwk_config": {
1530-
"anyOf": [
1531-
{
1532-
"$ref": "#/components/schemas/JwkConfiguration-Output"
1533-
},
1534-
{
1535-
"type": "null"
1536-
}
1537-
]
1538-
}
1539-
},
1540-
"additionalProperties": false,
1541-
"type": "object",
1542-
"title": "AuthenticationConfiguration",
1543-
"description": "Authentication configuration."
1544-
},
1545-
"AuthorizationConfiguration-Input": {
1546-
"properties": {
1547-
"access_rules": {
1548-
"items": {
1549-
"$ref": "#/components/schemas/AccessRule"
1550-
},
1551-
"type": "array",
1552-
"title": "Access Rules"
1553-
}
1554-
},
1555-
"additionalProperties": false,
1556-
"type": "object",
1557-
"title": "AuthorizationConfiguration",
1558-
"description": "Authorization configuration."
1559-
},
1560-
"AuthorizationConfiguration-Output": {
1602+
"AuthorizationConfiguration": {
15611603
"properties": {
15621604
"access_rules": {
15631605
"items": {
@@ -1753,12 +1795,12 @@
17531795
"title": "Mcp Servers"
17541796
},
17551797
"authentication": {
1756-
"$ref": "#/components/schemas/AuthenticationConfiguration-Output"
1798+
"$ref": "#/components/schemas/AuthenticationConfiguration"
17571799
},
17581800
"authorization": {
17591801
"anyOf": [
17601802
{
1761-
"$ref": "#/components/schemas/AuthorizationConfiguration-Output"
1803+
"$ref": "#/components/schemas/AuthorizationConfiguration"
17621804
},
17631805
{
17641806
"type": "null"
@@ -2717,7 +2759,7 @@
27172759
"title": "JsonPathOperator",
27182760
"description": "Supported operators for JSONPath evaluation."
27192761
},
2720-
"JwkConfiguration-Input": {
2762+
"JwkConfiguration": {
27212763
"properties": {
27222764
"url": {
27232765
"type": "string",
@@ -2726,7 +2768,7 @@
27262768
"title": "Url"
27272769
},
27282770
"jwt_configuration": {
2729-
"$ref": "#/components/schemas/JwtConfiguration-Input"
2771+
"$ref": "#/components/schemas/JwtConfiguration"
27302772
}
27312773
},
27322774
"additionalProperties": false,
@@ -2737,52 +2779,7 @@
27372779
"title": "JwkConfiguration",
27382780
"description": "JWK configuration."
27392781
},
2740-
"JwkConfiguration-Output": {
2741-
"properties": {
2742-
"url": {
2743-
"type": "string",
2744-
"minLength": 1,
2745-
"format": "uri",
2746-
"title": "Url"
2747-
},
2748-
"jwt_configuration": {
2749-
"$ref": "#/components/schemas/JwtConfiguration-Output"
2750-
}
2751-
},
2752-
"additionalProperties": false,
2753-
"type": "object",
2754-
"required": [
2755-
"url"
2756-
],
2757-
"title": "JwkConfiguration",
2758-
"description": "JWK configuration."
2759-
},
2760-
"JwtConfiguration-Input": {
2761-
"properties": {
2762-
"user_id_claim": {
2763-
"type": "string",
2764-
"title": "User Id Claim",
2765-
"default": "user_id"
2766-
},
2767-
"username_claim": {
2768-
"type": "string",
2769-
"title": "Username Claim",
2770-
"default": "username"
2771-
},
2772-
"role_rules": {
2773-
"items": {
2774-
"$ref": "#/components/schemas/JwtRoleRule"
2775-
},
2776-
"type": "array",
2777-
"title": "Role Rules"
2778-
}
2779-
},
2780-
"additionalProperties": false,
2781-
"type": "object",
2782-
"title": "JwtConfiguration",
2783-
"description": "JWT configuration."
2784-
},
2785-
"JwtConfiguration-Output": {
2782+
"JwtConfiguration": {
27862783
"properties": {
27872784
"user_id_claim": {
27882785
"type": "string",

src/app/endpoints/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def select_model_and_provider_id(
476476
"""
477477
# If no models are available, raise an exception
478478
if not models:
479-
message = "No LLM model found in available models"
479+
message = "No models available"
480480
logger.error(message)
481481
raise HTTPException(
482482
status_code=status.HTTP_404_NOT_FOUND,
@@ -515,7 +515,7 @@ def select_model_and_provider_id(
515515
model_label = model_id.split("/", 1)[1] if "/" in model_id else model_id
516516
return model_id, model_label, provider_id
517517
except (StopIteration, AttributeError) as e:
518-
message = "No LLM model found in available models"
518+
message = "No models available"
519519
logger.error(message)
520520
raise HTTPException(
521521
status_code=status.HTTP_404_NOT_FOUND,

tests/e2e/features/query.feature

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ Feature: Query endpoint API tests
9999
And The body of the response contains Conversation not found
100100

101101
Scenario: Check if LLM responds for query request with error for missing query
102-
103102
Given The system is in default state
104103
And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva
105104
When I use "query" to ask question with authorization header
@@ -168,9 +167,9 @@ Feature: Query endpoint API tests
168167
}
169168
"""
170169
Then The status code of the response is 200
171-
Scenario: Check if LLM responds with an error when no models are configured
172-
Given The service is started locally
173-
And REST API service prefix is /v1
170+
171+
@no_models
172+
Scenario: Check if LLM responds with an error when no models are configured
174173
Given The system is in default state
175174
And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva
176175
When I use "query" to ask question with authorization header

tests/e2e/features/streaming_query.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Feature: streaming_query endpoint API tests
126126
"""
127127
{"query": "Say hello"}
128128
"""
129-
Then The status code of the response is 400
129+
Then The status code of the response is 401
130130
And The body of the response is the following
131131
"""
132132
{"detail": "No Authorization header found"}

0 commit comments

Comments
 (0)