rusackas commented on code in PR #42597:
URL: https://github.com/apache/superset/pull/42597#discussion_r3709827996
##########
superset/common/query_object.py:
##########
@@ -440,6 +440,18 @@ def cache_key(self, **extra: Any) -> str: # noqa: C901
cache_dict: dict[str, Any] = dict(self.to_dict())
cache_dict.update(extra)
+ if "extra_cache_keys" in cache_dict:
+ # Order carries no meaning here (an unordered set of opaque
+ # Jinja url_param()-derived values), but hash_from_dict only
+ # sorts dict keys, not list values, so an unsorted list makes
+ # the cache key depend on Python's per-process hash-randomized
+ # set iteration order (see SqlaTable.get_extra_cache_keys).
+ # Normalize once here so every producer of extra_cache_keys is
+ # safe by construction.
+ cache_dict["extra_cache_keys"] = sorted(
+ cache_dict["extra_cache_keys"], key=str
+ )
Review Comment:
Good catch, `key=str` treats `1` and `"1"` as equal so ties could fall back
to set-iteration order. Switched to `(type(value).__name__, str(value))` and
added a test for it.
--
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]