chore: improve validation failed error for max ai surveys (#37270)

This commit is contained in:
Lucas Faria
2025-08-28 19:05:39 -03:00
committed by GitHub
parent eb0e3cc220
commit 6601d047ce
4 changed files with 14 additions and 5 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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:

View File

@@ -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