fix: Chart cache-warmup task fails on Superset 4.0 (#28706)

This commit is contained in:
Ross Masters
2024-09-07 01:56:14 +01:00
committed by GitHub
parent d7547fc4ef
commit 0744abe87b
4 changed files with 126 additions and 7 deletions

View File

@@ -29,6 +29,7 @@ from superset.models.core import Log
from superset.models.dashboard import Dashboard
from superset.models.slice import Slice
from superset.tags.models import Tag, TaggedObject
from superset.tasks.utils import fetch_csrf_token
from superset.utils import json
from superset.utils.date_parser import parse_human_datetime
from superset.utils.machine_auth import MachineAuthProvider
@@ -219,7 +220,10 @@ def fetch_url(data: str, headers: dict[str, str]) -> dict[str, str]:
"""
result = {}
try:
url = get_url_path("Superset.warm_up_cache")
# Fetch CSRF token for API request
headers.update(fetch_csrf_token(headers))
url = get_url_path("ChartRestApi.warm_up_cache")
logger.info("Fetching %s with payload %s", url, data)
req = request.Request(
url, data=bytes(data, "utf-8"), headers=headers, method="PUT"