etr2460 commented on a change in pull request #12080:
URL: 
https://github.com/apache/incubator-superset/pull/12080#discussion_r545523597



##########
File path: superset/views/core.py
##########
@@ -2511,31 +2512,32 @@ def sql_json_exec(  # pylint: 
disable=too-many-statements,too-many-locals
                 query.sql, **template_params
             )
         except TemplateError as ex:
-            error_msg = utils.error_msg_from_exception(ex)
-            return json_error_response(
-                f"Query {query_id}: Template syntax error: {error_msg}"
+            query.status = QueryStatus.FAILED
+            session.commit()
+            raise SupersetTemplateParamsErrorException(
+                utils.error_msg_from_exception(ex)
             )
 
-        # pylint: disable=protected-access
         if is_feature_enabled("ENABLE_TEMPLATE_PROCESSING"):
+            # pylint: disable=protected-access
             ast = template_processor._env.parse(rendered_query)
             undefined = find_undeclared_variables(ast)  # type: ignore
             if undefined:
-                error = SupersetError(
+                query.status = QueryStatus.FAILED
+                session.commit()
+                raise SupersetTemplateParamsErrorException(
                     message=ngettext(
-                        "There's an error with the parameter %(parameters)s.",
-                        "There's an error with the parameters %(parameters)s.",
+                        "The parameter %(parameters)s in your query is 
undefined.",
+                        "The following parameters in your query are undefined: 
%(parameters)s.",
                         len(undefined),
                         parameters=utils.format_list(undefined),
                     )
                     + " "
                     + PARAMETER_MISSING_ERR,
-                    level=ErrorLevel.ERROR,
-                    error_type=SupersetErrorType.MISSING_TEMPLATE_PARAMS_ERROR,
-                    extra={"missing_parameters": list(undefined)},
-                )
-                return json_error_response(
-                    payload={"errors": [dataclasses.asdict(error)]},
+                    extra={
+                        "undefined_parameters": list(undefined),
+                        "template_parameters": template_params,
+                    },

Review comment:
       should we update the unit test for the params error to check for the 
extra payload too?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to