From 73e53fab7a5141881711a0269740627fd0527d30 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Tue, 10 Jan 2023 22:14:51 +0200 Subject: [PATCH] fix(bootstrap-data): always check flashes (#22659) --- superset/views/base.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/superset/views/base.py b/superset/views/base.py index d16baecc735c0..41a27b4139e9c 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -388,13 +388,12 @@ def menu_data(user: User) -> Dict[str, Any]: @cache_manager.cache.memoize(timeout=60) -def common_bootstrap_payload(user: User) -> Dict[str, Any]: +def cached_common_bootstrap_data(user: User) -> Dict[str, Any]: """Common data always sent to the client - The function is memoized as the return value only changes based - on configuration and feature flag values. + The function is memoized as the return value only changes when user permissions + or configuration values change. """ - messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) # should not expose API TOKEN to frontend @@ -418,7 +417,6 @@ def common_bootstrap_payload(user: User) -> Dict[str, Any]: frontend_config["HAS_GSHEETS_INSTALLED"] = bool(available_specs[GSheetsEngineSpec]) bootstrap_data = { - "flash_messages": messages, "conf": frontend_config, "locale": locale, "language_pack": get_language_pack(locale), @@ -432,6 +430,13 @@ def common_bootstrap_payload(user: User) -> Dict[str, Any]: return bootstrap_data +def common_bootstrap_payload(user: User) -> Dict[str, Any]: + return { + **(cached_common_bootstrap_data(user)), + "flash_messages": get_flashed_messages(with_categories=True), + } + + def get_error_level_from_status_code( # pylint: disable=invalid-name status: int, ) -> ErrorLevel: