Skip to content

Superset no longer accepts custom jinja template functions for caching #33775

@neuromantik33

Description

@neuromantik33

Bug description

There is a regression in the PR fix(Jinja): Extra cache keys to consider vars with set #30549 . I mentioned it as a comment within the PR but I guess since it's merged I'm filing a proper bug report.

This PR breaks are existing usage of RLS (thank heavens one for our campus users notified us 😅 ). This is our input string:

campus_id IN UNNEST( {{ cache_key_wrapper(current_user_campus_ids()) }} )

which doesn't match using the pattern : cache_key_wrapper\([^()]*\),
but does using the old one (v4.0.2): cache_key_wrapper\(.*\).

The function we use looks as follows:

def current_user_campus_ids() -> list[int]:
    """
    Get the list of campus ids associated with the current user
    """
    user: FortyTwoUser = g.user
    return user.campus_ids()

and is populated using the oauth2 jwt from keycloak.
Is the only workaround to monkey patch the jinja ExtraCache processor to add our macro within? How is the cache_key_wrapper() to be used if it can't invoke another function?

Screenshots/recordings

No response

Superset version

4.1.2

Python version

3.10

Node version

I don't know

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions