Open nsivarajan opened 4 days ago
Attention: Patch coverage is 53.84615%
with 6 lines
in your changes missing coverage. Please review.
Project coverage is 83.80%. Comparing base (
76d897e
) to head (e6a2aa5
). Report is 1096 commits behind head on master.
Files with missing lines | Patch % | Lines |
---|---|---|
superset/tasks/cache.py | 50.00% | 6 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
SUMMARY
This PR addresses #30900, which reports a "400 Bad Request: The CSRF session token is missing" error during cache warmup. The issue was due to missing header updates with the CSRF token and cookie (expecting session='session_cookie'). This PR ensures the token is correctly fetched and included in headers during the warmup process, resolving the error.
Fixes https://github.com/apache/superset/issues/30900
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Success:
TESTING INSTRUCTIONS
Since we are now explicitly fetching the CSRF token, we can enable
WTF_CSRF_ENABLED = True
or safely removeWTF_CSRF_EXEMPT_LIST
for any cache warmup-related endpoints. This ensures that all requests, including those for cache warmup, are properly validated with CSRF protection, thereby enhancing application security.If CSRF protection is disabled or the endpoint is exempted, no CSRF checks will be performed. However, the
ChartRestApi.warm_up_cache
endpoint still requires a session cookie (session=session_cookie
) to determine the user's context and permissions. Without this, the request will fail with a401 Unauthorized error
.This PR ensures the session cookie is correctly updated in the request headers under the Cookie field, enabling the user context to be accurately resolved for authorization.
ADDITIONAL INFORMATION