PiXOT97 opened a new issue, #34543:
URL: https://github.com/apache/superset/issues/34543

   ### Bug description
   
   Apache Superset Version: 4.1.2
   Deployment: Dockerized, with two VMs (one for Superset web UI, one for 
Celery workers)
   Domain: Both services under the same domain
   
   **Issue**
   
   When embedding a dashboard via iframe, queries using a single Jinja filter 
work correctly. However, when using multiple Jinja parameters, Superset fails 
to retrieve cached results.
   
   Embedded dashboards with multiple Jinja filters cannot load correct data. 
Breaks embedding functionality in production scenarios where filtering is 
critical.
   
   <img width="1267" height="938" alt="Image" 
src="https://github.com/user-attachments/assets/30a994b9-2362-4c00-8731-e7b8d73a5c05";
 />
   
   **Request/Response Sequence**
   
   **Embedded Dashboard Request**
   
   `GET 
/embedded/<uuid>?CAR_IDS=...&CHASSIS_IDS=...&START_DATE=2025-07-01&END_DATE=2025-08-31`
   
   - Returns 200 OK.
   - Dashboard renders, initiating async queries.
   
   **Async Event Polling**
   
   `GET /api/v1/async_event/`
   
   - Response 200 OK → status: done, includes a result_url to cached data.
   
   **Data Retrieval Request**
   
   `GET /api/v1/chart/data/<cache_key>`
   
   - Expected: Retrieve cached result from Redis.
   - Actual: 422 Unprocessable Entity
   - {"message": "Error loading data from cache"}
   
   **Debugging Performed**
   
   - Verified Celery worker writes results successfully to Redis.
   - Inspected Redis with Redis Commander: cache key exists.
   - Web UI fails to load the cached payload → mismatch between write/read 
phases.
   - Confirmed both services use the same Redis instance and DB in 
superset_config.py.
   - Observed the error only when multiple URL parameters (comma-separated) are 
passed.
   
   **Jinja Template Context**
   
   ```
   SELECT * FROM v_tx_facts_metadata
   WHERE car_ids && string_to_array('{{ url_param("CAR_IDS") }}', 
',')::varchar[]
   AND chassis_ids && string_to_array('{{ url_param("CHASSIS_IDS") }}', 
',')::varchar[]
   AND date BETWEEN '{{ url_param("START_DATE") }}' AND '{{ 
url_param("END_DATE") }}'
   ```
   
   **Attempted Workaround**
   
   Used url_param('param', add_to_cache_keys=False) to exclude filters from 
cache keys.
   
   Result: Eliminated the 422 error but produced incorrect results, as Superset 
reused the base cached query regardless of filter values.
   
   Additionally, tested disabling GLOBAL_ASYNC_QUERIES. This allowed the 
dashboard to work with multiple parameters, but it bypassed the Celery workers 
entirely, forcing synchronous execution. This resolves the cache mismatch but 
sacrifices async processing and scalability.
   
   Root Cause (based on analysis and related GitHub issues #24171, #31492, PR 
#25549)
   
   - Cache key serialization/encoding issues with multiple parameters.
   - Inconsistent cache key generation between Celery worker (write) and web UI 
(read).
   - Issue specific to embedded dashboards with async queries and Jinja filters.
   
   
   Expected Behavior
   
   Multi-parameter Jinja queries should correctly generate and retrieve cache 
keys.
   
   Filters applied via URL parameters should not break async query caching.
   
   
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [ ] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [ ] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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.

To unsubscribe, e-mail: [email protected]

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