FrancescoCastaldi commented on code in PR #45895:
URL: https://github.com/apache/superset/pull/45895#discussion_r4431156530
##########
superset/semantic_layers/models.py:
##########
@@ -905,6 +905,23 @@ def get_extra_cache_keys(self, query_obj: QueryObjectDict)
-> list[Hashable]:
keys: list[Hashable] = [self.metadata_generation,
"semantic-null-filters-v1"]
if discriminator is not None:
keys.append(("semantic-result-version", *discriminator))
+
+ from superset import is_feature_enabled
+
+ if is_feature_enabled("CACHE_QUERY_BY_USER"):
+ try:
+ from superset.semantic_layers.execution import (
+ current_host_execution_context,
+ )
+
+ exec_context = current_host_execution_context()
+ if not exec_context.is_guest and exec_context.identity_digest:
+ keys.append(("semantic-user",
exec_context.identity_digest))
+ except Exception as ex:
+ logger.debug(
+ "Could not resolve semantic execution context for cache:
%s", ex
+ )
Review Comment:
Resolved in commit 3895a3a996.
When CACHE_QUERY_BY_USER is enabled and context resolution encounters an
unexpected failure, we now log a warning and append a distinct nonce
`('semantic-user-unresolved', uuid.uuid4().hex)`. This ensures fail-safe user
isolation so that failed context resolutions never collapse into a shared
unpartitioned cache key or leak semantic results across users. Dedicated test
coverage has been added in `tests/unit_tests/semantic_layers/models_test.py`
exercising this fallback branch, ensuring 100% module coverage.
--
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]