mirror of
https://github.com/BillyOutlast/posthog.git
synced 2026-02-04 03:01:23 +01:00
chore: improve validation failed error for max ai surveys (#37270)
This commit is contained in:
@@ -80,7 +80,12 @@ function NewSurveyButton(): JSX.Element {
|
||||
context={{
|
||||
user_id: user.uuid,
|
||||
}}
|
||||
callback={(toolOutput: { survey_id?: string; survey_name?: string; error?: string }) => {
|
||||
callback={(toolOutput: {
|
||||
survey_id?: string
|
||||
survey_name?: string
|
||||
error?: string
|
||||
error_message?: string
|
||||
}) => {
|
||||
addProductIntent({
|
||||
product_type: ProductKey.SURVEYS,
|
||||
intent_context: ProductIntentContext.SURVEY_CREATED,
|
||||
|
||||
@@ -120,7 +120,11 @@ export function SurveysEmptyState({ numOfSurveys }: Props): JSX.Element {
|
||||
'Create a feedback survey asking about our new dashboard',
|
||||
]}
|
||||
context={{ user_id: user.uuid }}
|
||||
callback={(toolOutput: { survey_id?: string; error?: string }) => {
|
||||
callback={(toolOutput: {
|
||||
survey_id?: string
|
||||
error?: string
|
||||
error_message?: string
|
||||
}) => {
|
||||
addProductIntent({
|
||||
product_type: ProductKey.SURVEYS,
|
||||
intent_context: ProductIntentContext.SURVEY_CREATED,
|
||||
|
||||
@@ -88,7 +88,7 @@ class CreateSurveyTool(MaxTool):
|
||||
if not result.questions:
|
||||
return "❌ Survey must have at least one question", {
|
||||
"error": "validation_failed",
|
||||
"details": "No questions provided",
|
||||
"error_message": "No questions were created from the survey instructions.",
|
||||
}
|
||||
|
||||
# Apply appearance defaults and prepare survey data
|
||||
@@ -110,7 +110,7 @@ class CreateSurveyTool(MaxTool):
|
||||
except Exception as validation_error:
|
||||
return f"❌ Survey validation failed: {str(validation_error)}", {
|
||||
"error": "validation_failed",
|
||||
"details": str(validation_error),
|
||||
"error_message": str(validation_error),
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -127,7 +127,7 @@ class TestSurveyCreatorTool(BaseTest):
|
||||
# Verify error response
|
||||
assert "❌ Survey must have at least one question" in content
|
||||
assert artifact["error"] == "validation_failed"
|
||||
assert "No questions provided" in artifact["details"]
|
||||
assert "No questions were created from the survey instructions" in artifact["error_message"]
|
||||
|
||||
@patch.object(CreateSurveyTool, "_create_survey_from_instructions")
|
||||
@pytest.mark.django_db
|
||||
|
||||
Reference in New Issue
Block a user