codeant-ai-for-open-source[bot] commented on code in PR #45537:
URL: https://github.com/apache/superset/pull/45537#discussion_r4331625936


##########
superset/semantic_layers/exceptions.py:
##########
@@ -100,6 +100,45 @@ def __init__(self) -> None:
         )
 
 
+ProviderResult = TypeVar("ProviderResult")
+
+# Host signals that keep their own classification when raised by a provider.
+_HOST_SIGNALS: tuple[type[BaseException], ...] = (
+    QueryObjectValidationError,
+    SemanticLayerQueryRejectedError,
+    SemanticLayerExecutionError,
+    SupersetSecurityException,
+    OAuth2RedirectError,
+    OAuth2Error,
+    SupersetCancelQueryException,
+    SoftTimeLimitExceeded,
+)
+
+
+def discover_semantic_metadata(
+    discovery: Callable[[], ProviderResult],
+) -> ProviderResult:
+    """
+    Classify a provider metadata fault as a backend error.
+
+    Discovery takes no user input, so a provider exception here is never a
+    correctable request; it must not reach generic ``ValueError`` handlers
+    that answer 400, and its text must not reach the response. This helper
+    logs only the exception type: discovery also runs for dashboards and
+    metadata views, whose logs must not carry provider detail.
+    """
+    try:
+        return discovery()
+    except _HOST_SIGNALS:
+        raise
+    except Exception as ex:  # pylint: disable=broad-except
+        # Provider exception text may contain credentials or provider URLs.
+        logger.error(
+            "Semantic provider metadata discovery failed: %s", 
type(ex).__name__
+        )
+        raise SemanticLayerExecutionError() from ex

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `cbe2b47`.
   
   Metadata discovery errors are raised as `SemanticLayerExecutionError() from 
None`, suppressing the provider exception cause and traceback.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



##########
superset/semantic_layers/models.py:
##########
@@ -606,6 +607,14 @@ def uid(self) -> str:
     def type(self) -> str:
         return "semantic_view"
 
+    def _provider_metrics(self) -> set[Metric]:
+        """Read the provider's metrics, classifying faults as backend 
errors."""
+        return discover_semantic_metadata(self.implementation.get_metrics)
+
+    def _provider_dimensions(self) -> set[Dimension]:
+        """Read the provider's dimensions, classifying faults as backend 
errors."""
+        return discover_semantic_metadata(self.implementation.get_dimensions)

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `cbe2b47`.
   
   The provider access is inside a lambda passed to 
`discover_semantic_metadata`, so resolving `self.implementation` and calling 
`get_dimensions()` occur within the wrapper’s error-classification boundary.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



-- 
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]

Reply via email to