bito-code-review[bot] commented on code in PR #42929:
URL: https://github.com/apache/superset/pull/42929#discussion_r3763972468


##########
superset/models/helpers.py:
##########
@@ -329,6 +329,62 @@ def validate_stored_expression_at_query_time(
     return expression
 
 
+def validate_rendered_expression(

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing test coverage</b></div>
   <div id="fix">
   
   A new public function `validate_rendered_expression` has been added with no 
corresponding test coverage. The `validate_stored_expression_at_query_time` 
function above (line 270) has tests in 
`tests/unit_tests/models/helpers_test.py`; the new function should receive 
equivalent coverage.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #5a1d2b</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset/models/helpers.py:
##########
@@ -3020,9 +3080,40 @@ def get_from_clause(
                 if rls_applied:
                     from_sql = parsed_script.format()
 
-            except Exception as ex:
-                # Log the error but don't fail - RLS application is best-effort
-                logger.warning("Failed to apply RLS to virtual dataset SQL: 
%s", ex)
+            except Exception as ex:  # pylint: disable=broad-except
+                # RLS injection failures fail closed: only continue when it is
+                # positively confirmed that no RLS predicates apply to the
+                # referenced tables; any other outcome aborts the query.
+                try:
+                    rls_required = any(
+                        get_predicates_for_table(
+                            table.qualify(
+                                catalog=self.catalog,
+                                schema=self.schema or default_schema or "",
+                            ),
+                            self.database,
+                            self.database.get_default_catalog(),
+                            exclude_dataset_id=self_id,
+                        )
+                        for statement in parsed_script.statements
+                        for table in statement.tables
+                    )
+                except Exception:  # pylint: disable=broad-except

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Broad exception clause detected</b></div>
   <div id="fix">
   
   Catching broad `Exception` is discouraged. Consider catching specific 
exceptions like `ValueError` or using `ExceptionGroup` to preserve exception 
context.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #2ce454</i></small>
   </div><div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Avoid catching generic Exception</b></div>
   <div id="fix">
   
   Replace the broad `Exception` catch with more specific exception types to 
avoid silently masking unexpected errors. Other similar exception handlers 
exist at lines 3160 and 3163-3164 in this function.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #5a1d2b</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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