bito-code-review[bot] commented on PR #44553:
URL: https://github.com/apache/superset/pull/44553#issuecomment-5787696772

   <!-- Bito Reply -->
   The flagged issue is correct. The current implementation of 
`get_object_ids_from_view_args` calls `_resolve_object_id` unconditionally for 
routes with matching arguments, which triggers a database query to resolve 
slugs or UUIDs to integer IDs before the handler executes. This adds latency 
and can cause issues if the database session is unavailable.
   
   To resolve this, you can modify `get_object_ids_from_view_args` to check if 
the logger is actually configured to use the database before performing the 
lookup. Alternatively, you could defer the resolution until the logger actually 
needs the ID, though that would require more significant changes to the logging 
infrastructure.
   
   Here is a concise fix to avoid the database query if the logger is not 
configured to use the database:
   
   ```python
   # superset/utils/log.py
   
   def get_object_ids_from_view_args(
       view: Any, view_args: dict[str, Any]
   ) -> dict[str, Any]:
       # ... existing code ...
       if column is None or not stats_logger_manager.is_db_logger_configured():
           return {}
   
       for key in OBJECT_ID_VIEW_ARGS:
           # ... existing code ...
   ```
   
   I have checked the PR and there are no other comments to address. Would you 
like me to implement this fix?
   
   **superset/utils/log.py**
   ```
   model = getattr(getattr(view, "datamodel", None), "obj", None)
       column = LOG_OBJECT_ID_COLUMNS.get(getattr(model, "__name__", ""))
       if column is None or not stats_logger_manager.is_db_logger_configured():
           return {}
   ```


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