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


##########
superset/mcp_service/dashboard/tool/generate_dashboard.py:
##########
@@ -227,6 +227,23 @@ def generate_dashboard(
                     error=f"Charts not found: {list(missing_chart_ids)}",
                 )
 
+            # Validate dataset access for each chart using the same
+            # pattern as get_chart_info / get_chart_data / get_chart_preview.
+            from superset.mcp_service.chart.chart_utils import (
+                validate_chart_dataset,
+            )
+
+            for chart in chart_objects:
+                validation = validate_chart_dataset(chart, check_access=True)
+                if not validation.is_valid:
+                    return GenerateDashboardResponse(
+                        dashboard=None,
+                        dashboard_url=None,
+                        error=(
+                            f"Chart {chart.id} is not accessible: 
{validation.error}"
+                        ),
+                    )

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Error handling regression in multi-chart 
validation</b></div>
   <div id="fix">
   
   The new validation stops at the first inaccessible chart, but the original 
code collected all inaccessible charts for better UX. Since generate_dashboard 
handles multiple charts like generate_chart does, collect all errors to match 
that pattern and avoid iterative fixes.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
               errors = []
               for chart in chart_objects:
                   validation = validate_chart_dataset(chart, check_access=True)
                   if not validation.is_valid:
                       errors.append(f"Chart {chart.id} is not accessible: 
{validation.error}")
               if errors:
                   return GenerateDashboardResponse(
                       dashboard=None,
                       dashboard_url=None,
                       error="; ".join(errors),
                   )
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #57d487</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