You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rahul-plavelimana (via GitHub)" <gi...@apache.org> on 2025/09/22 07:51:53 UTC

[I] Using Jinja SQLs in charts + enabling async execution results in HTTP error 422 - UNPROCESSABLE ENTITY [superset]

rahul-plavelimana opened a new issue, #35226:
URL: https://github.com/apache/superset/issues/35226

   ### Bug description
   
   Steps to replicate:
   
   1. Define a chart with some jinja SQLs, referencing columns dynamically based on a dashboard level filter
   2. Keep async enabled
   	GLOBAL_ASYNC_QUERIES = True
   	ENABLE_ASYNC_QUERIES = True
   3. Load the dashboard
   
   Scenario:
   
   I have a chart in which we have defined a custom metric using jinja SQLs
   
   It looks as below where
   
   `MAX(
       {% if filter_values('perfmetrics')|length %}
           {% set metric_value = filter_values('perfmetrics')[0] %}
           {% if metric_value == 'Total IOPs' %}
               vlun_iops_total
           {% elif metric_value == 'Read IOPs' %}
               vlun_iops_read
           {% elif metric_value == 'Write IOPs' %}
               vlun_iops_write
           {% elif metric_value == 'Total Latency (ms)' %}
               vlun_svt_total
           {% elif metric_value == 'Read Latency (ms)' %}
               vlun_svt_read
           {% elif metric_value == 'Write Latency (ms)' %}
               vlun_svt_write
           {% elif metric_value == 'Total Throughput (MiB/s)' %}
               vlun_kbps_total/1024
           {% elif metric_value == 'Read Throughput (MiB/s)' %}
               vlun_kbps_read/1024
           {% elif metric_value == 'Write Throughput (MiB/s)' %}
               vlun_kbps_write/1024
           {% elif metric_value == 'Total IO Size (KiB)' %}
               vlun_iosz_total
           {% elif metric_value == 'Read IO Size (KiB)' %}
               vlun_iosz_read
           {% elif metric_value == 'Write IO Size (KiB)' %}
               vlun_iosz_write
           {% endif %}
       {% endif %}
   )`
   
   perfmetrics => This is a list filter at dashboard level, where we can pick values as 'Total IOPs' / 'Read IOPs' / 'Write IOPs' etc. 
   
   Based on the user selection, we select the right database column and aggregate it. All of the columns are of type "double".
   
   With async disabled, charts are loading fine.
   
   If async is enabled, 
   
   <img width="1014" height="465" alt="Image" src="https://github.com/user-attachments/assets/2653a106-9dbd-408f-a4d6-2684f62705b5" />
   
   Superset version: 3.0.0
   
   we are getting "422 UNPROCESSABLE ENTITY", in the UI it shows as unexpected error with no specific error message string.
   
   Error screenshots are similar to the ones seen in the thread "https://github.com/apache/superset/issues/34543"
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [x] 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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Using Jinja SQLs in charts + enabling async execution results in HTTP error 422 - UNPROCESSABLE ENTITY [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz closed issue #35226: Using Jinja SQLs in charts + enabling async execution results in HTTP error 422 - UNPROCESSABLE ENTITY
URL: https://github.com/apache/superset/issues/35226


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Using Jinja SQLs in charts + enabling async execution results in HTTP error 422 - UNPROCESSABLE ENTITY [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #35226:
URL: https://github.com/apache/superset/issues/35226#issuecomment-3317426904

   <!-- Greeting -->
   Hi @rahul-plavelimana! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.
   
   <!-- Answer -->
   This is a known bug in Superset when using async queries with Jinja SQLs and dashboard-level filters: enabling `GLOBAL_ASYNC_QUERIES` causes HTTP 422 errors due to inconsistent cache key serialization between the Celery worker (which writes the cache) and the web UI (which reads it). This mismatch happens especially when multiple URL parameters or Jinja filters are involved, so the cache key generated during async execution doesn't match the one used for retrieval, even though the result exists in Redis. See [issue #34543](https://github.com/apache/superset/issues/34543) for details.
   
   Workarounds are limited: disabling async (`GLOBAL_ASYNC_QUERIES = False`) avoids the bug but sacrifices scalability; using `url_param('param', add_to_cache_keys=False)` can bypass the error but breaks filtering, since the cache key no longer reflects filter values. There’s no official fix as of now, and the bug persists in master/latest-dev. If you need async and dynamic Jinja filters, you may need to limit to single-parameter filters or monitor for upstream changes. Advanced users can explore a custom patch to serialize URL parameters in a canonical way for cache keys—see the code paths in `superset/jinja_context.py`, `superset/common/query_object.py`, and `superset/connectors/sqla/models.py` for where this logic lives [source](https://github.com/apache/superset/issues/34543).
   
   For dynamic SQL logic, consider moving conditional logic into the main SQL query using CASE WHEN or virtual datasets, as Jinja templating in chart filters is no longer supported in recent versions [source](https://github.com/apache/superset/issues/34264).
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/cd033b53-661b-455f-82ca-fc2444821ce9?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/cd033b53-661b-455f-82ca-fc2444821ce9?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/cd033b53-661b-455f-82ca-fc2444821ce9?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/cd033b53-661b-455f-82ca-fc2444821ce9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cd033b53-661b-455f-82ca-fc2444821ce9?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/cd033b53-661b-455f-82ca-fc2444821ce9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cd033b53-661b-455f-82ca-fc2444821ce9?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=githu
 b)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/35226)


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Using Jinja SQLs in charts + enabling async execution results in HTTP error 422 - UNPROCESSABLE ENTITY [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on issue #35226:
URL: https://github.com/apache/superset/issues/35226#issuecomment-3320243877

   As dosu pointed out this is the same issue as [#34543](https://github.com/apache/superset/issues/34543). I still haven't got around to looking into this yet but if you have any ideas on how to fix it, we would appreciate it. Also closing this one as duplicate but thank you for the detailed report @rahul-plavelimana!


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org