Skip to content

Commit cc0c6bb

Browse files
committed
unit test
1 parent 103e243 commit cc0c6bb

3 files changed

Lines changed: 48 additions & 1 deletion

File tree

qtype/semantic/checker.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,24 @@ def _validate_application(application: Application) -> None:
624624
Raises:
625625
QTypeSemanticError: If SecretReference is used but
626626
secret_manager is not configured, or if secret_manager
627-
configuration is invalid
627+
configuration is invalid, or if feedback is configured
628+
without telemetry
628629
"""
630+
# Check if feedback is configured without telemetry
631+
if application.telemetry is None:
632+
flows_with_feedback = [
633+
flow.id for flow in application.flows if flow.feedback is not None
634+
]
635+
if flows_with_feedback:
636+
raise QTypeSemanticError(
637+
(
638+
f"Application '{application.id}' has flows with feedback "
639+
f"configured but no telemetry sink defined. "
640+
f"Flows with feedback: {', '.join(flows_with_feedback)}. "
641+
"Please add a telemetry configuration to the application."
642+
)
643+
)
644+
629645
if application.secret_manager is None:
630646
# Check if any SecretReference is used in the application
631647
if _has_secret_reference(application):
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
id: test_feedback_without_telemetry
2+
description: Test that feedback requires telemetry to be configured
3+
4+
flows:
5+
- id: chat
6+
description: Flow with feedback but no telemetry (should fail validation)
7+
interface:
8+
type: Conversational
9+
feedback:
10+
type: thumbs
11+
explanation: false
12+
variables:
13+
- id: msg
14+
type: ChatMessage
15+
steps:
16+
- type: Echo
17+
id: echo
18+
inputs:
19+
- msg
20+
outputs:
21+
- msg
22+
inputs:
23+
- msg
24+
outputs:
25+
- msg
26+
27+
# Note: No telemetry configured - this should cause validation error

tests/semantic/test_checker_validation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
"invalid_secret_manager_wrong_auth_type.qtype.yaml",
106106
"AWSSecretManager 'my_secret_manager' requires an AWSAuthProvider",
107107
),
108+
(
109+
"invalid_feedback_without_telemetry.qtype.yaml",
110+
"has flows with feedback configured but no telemetry sink defined",
111+
),
108112
(
109113
"invalid_complete_flow_no_text_output.qtype.yaml",
110114
"final step 'echo_step' is of type 'Echo' which does not support streaming",

0 commit comments

Comments
 (0)