dosubot[bot] commented on issue #33775:
URL: https://github.com/apache/superset/issues/33775#issuecomment-2973643081

   <!-- Answer -->
   This regression is due to a change in the regex used by Superset to detect 
cache key wrappers in Jinja templates—it now only allows simple, non-nested 
expressions like `cache_key_wrapper(foo)` and blocks nested calls like 
`cache_key_wrapper(current_user_campus_ids())` that worked in previous 
versions. This breaks use cases like yours for RLS and dynamic user-based cache 
keys. There’s currently no official workaround or extensibility for this in the 
code or docs, and no open issues or discussions about it in the repo.
   
   Monkey patching the Jinja `ExtraCache` processor is the only available 
workaround if you need to restore the previous behavior, since the regex 
restriction is hardcoded and there’s no config or plugin hook for extending 
cache key computation. If you go this route, be aware it’s an unsupported hack 
and could break with future updates. Otherwise, you’d need to refactor your 
templates to avoid nested calls, but that may not be possible for your use case.
   
   For reference, here’s the relevant implementation and restriction in the 
code:  
   [cache_key_wrapper and regex in 
ExtraCache](https://github.com/apache/superset/blob/8fd0fd673f3307ae2f7555272d68d8511651e685/superset/jinja_context.py)
  
   And the intended usage in the docs:  
   [SQL templating and 
cache_key_wrapper](https://github.com/apache/superset/blob/8fd0fd673f3307ae2f7555272d68d8511651e685/docs/docs/configuration/sql-templating.mdx)
   
   If you need to keep your current pattern, monkey patching is your only 
option until the project provides a more flexible or documented solution.
   
   
   <!-- 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/88e1f76e-ceb5-4fa8-8deb-1e98dc04b987?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/88e1f76e-ceb5-4fa8-8deb-1e98dc04b987?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/88e1f76e-ceb5-4fa8-8deb-1e98dc04b987?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/88e1f76e-ceb5-4fa8-8deb-1e98dc04b987?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/88e1f76e-ceb5-4fa8-8deb-1e98dc04b987?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/88e1f76e-ceb5-4fa8-8deb-1e98dc04b987?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/88e1f76e-ceb5-4fa8-8deb-1e98dc04b987?feedback_type=other)</sup>&nbsp;&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/33775)


-- 
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-unsubscr...@superset.apache.org

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


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

Reply via email to