GitHub user dosubot[bot] added a comment to the discussion: getting error 422 
/api/v1/chart/data/qc-a3....

<!-- Greeting -->
Hi @shobhit5090! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the 
superset team.

<!-- Answer -->
The 422 errors you're seeing on `/api/v1/chart/data/...` with Celery and Redis 
caching are a known Superset issue, especially when async queries are enabled 
and your chart SQL uses Jinja templating that references dashboard-level 
filters. The root cause is a mismatch in how cache keys are generated between 
the web UI and Celery worker, which leads to cache misses and unprocessable 
payloads—charts and filters then fail to load after cache timeout or on first 
load. You can confirm this by checking your Superset and Celery logs for 
messages like `force_cached (QueryContext): value not found for key ...` or 
template errors in Jinja expressions 
([details](https://github.com/apache/superset/issues/35226), 
[details](https://github.com/apache/superset/issues/35991)).

Workarounds:  
- Disable async queries by setting `GLOBAL_ASYNC_QUERIES = False` (this impacts 
scalability but avoids the bug).
- Avoid Jinja templating in chart filters—use CASE WHEN statements or virtual 
datasets for dynamic SQL logic instead.
- If you must use Jinja, avoid referencing dashboard filters or use 
`url_param('param', add_to_cache_keys=False)` (but this breaks filtering 
functionality).

There's no official fix yet, so if you need async queries and dashboard filters 
together, you'll need to refactor your chart SQL to avoid Jinja references to 
dashboard filters. If you want to isolate the issue, try disabling async 
queries or testing with a simple chart that doesn't use Jinja or dashboard 
filters ([source](https://github.com/apache/superset/issues/35226), 
[source](https://github.com/apache/superset/issues/35991)).


<!-- 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/b079854c-f15c-4404-8bab-c95c55d59949?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/b079854c-f15c-4404-8bab-c95c55d59949?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/b079854c-f15c-4404-8bab-c95c55d59949?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/b079854c-f15c-4404-8bab-c95c55d59949?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/b079854c-f15c-4404-8bab-c95c55d59949?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/b079854c-f15c-4404-8bab-c95c55d59949?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/b079854c-f15c-4404-8bab-c95c55d59949?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20422%20errors%20you%27re%20seeing%20on%20%60/api/v1/chart/data/...%60%20with%20Celery%20and%20Redis%20caching%20are%20a%20known%20Superset%20issue%2C%20especially%20when%20async%20queries%20are%20enabled%20and%20your%20chart%20SQL%20uses%20Jinja%20templating%20that%20references%20dashboard-level%20filters.%20The%20root%20cause%20is%20a%20mismatch%20in%20how%20cache%20keys%20are%20generated%20between%20the%20web%20UI%20and%20Celery%20worker%2C%20which%20leads%20to%20cache%20misses%20and%20unprocessable%20payloads%E2%80%94charts%20and%20filters%20then%20fail%20to%20load%20after%20cache%20timeout%20or%20on%20first%20load.%20You%20can%20confirm%20this%20by%20checking%20your%20Superset%20and%20Celery%20logs%20for%20messages%20like%20%60force_cached%20
 
%28QueryContext%29%3A%20value%20not%20found%20for%20key%20...%60%20or%20template%20errors%20in%20Jinja%20expressions%C2%A0%28%5Bdetails%5D%28https%3A//github.com/apache/superset/issues/35226%29%2C%20%5Bdetails%5D%28https%3A//github.com/apache/superset/issues/35991%29%29.%0A%0AWorkarounds%3A%20%20%0A-%20Disable%20async%20queries%20by%20setting%20%60GLOBAL_ASYNC_QUERIES%20%3D%20False%60%20%28this%20impacts%20scalability%20but%20avoids%20the%20bug%29.%0A-%20Avoid%20Jinja%20templating%20in%20chart%20filters%E2%80%94use%20CASE%20WHEN%20statements%20or%20virtual%20datasets%20for%20dynamic%20SQL%20logic%20instead.%0A-%20If%20you%20must%20use%20Jinja%2C%20avoid%20referencing%20dashboard%20filters%20or%20use%20%60url_param%28%27param%27%2C%20add_to_cache_keys%3DFalse%29%60%20%28but%20this%20breaks%20filtering%20functionality%29.%0A%0AThere%27s%20no%20official%20fix%20yet%2C%20so%20if%20you%20need%20async%20queries%20and%20dashboard%20filters%20together%2C%20you%27ll%20need%20to%20refactor%20
 
your%20chart%20SQL%20to%20avoid%20Jinja%20references%20to%20dashboard%20filters.%20If%20you%20want%20to%20isolate%20the%20issue%2C%20try%20disabling%20async%20queries%20or%20testing%20with%20a%20simple%20chart%20that%20doesn%27t%20use%20Jinja%20or%20dashboard%20filters%C2%A0%28%5Bsource%5D%28https%3A//github.com/apache/superset/issues/35226%29%2C%20%5Bsource%5D%28https%3A//github.com/apache/superset/issues/35991%29%29.)&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/discussions/37306)

GitHub link: 
https://github.com/apache/superset/discussions/37306#discussioncomment-15560667

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to