fix: url_params cache miss with global async query (#23641)

This commit is contained in:
Kenny Kwan 2023-04-13 13:35:02 -07:00 committed by GitHub
parent 26250173ab
commit 19404bc13e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -21,7 +21,7 @@ import logging
from typing import Any, Dict, Optional, TYPE_CHECKING, Union
import simplejson
from flask import current_app, make_response, request, Response
from flask import current_app, g, make_response, request, Response
from flask_appbuilder.api import expose, protect
from flask_babel import gettext as _
from marshmallow import ValidationError
@ -299,6 +299,9 @@ class ChartDataRestApi(ChartRestApi):
"""
try:
cached_data = self._load_query_context_form_from_cache(cache_key)
# Set form_data in Flask Global as it is used as a fallback
# for async queries with jinja context
setattr(g, "form_data", cached_data)
query_context = self._create_query_context_from_form(cached_data)
command = ChartDataCommand(query_context)
command.validate()

View File

@ -583,7 +583,9 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
form_data = cached.get("form_data")
response_type = cached.get("response_type")
# Set form_data in Flask Global as it is used as a fallback
# for async queries with jinja context
setattr(g, "form_data", form_data)
datasource_id, datasource_type = get_datasource_info(None, None, form_data)
viz_obj = get_viz(