korbit-ai[bot] commented on code in PR #25102:
URL: https://github.com/apache/superset/pull/25102#discussion_r1913748526


##########
superset/commands/dashboard/importers/v1/__init__.py:
##########
@@ -120,32 +120,32 @@
                 charts.append(chart)
                 chart_ids[str(chart.uuid)] = chart.id
 
-        # store the existing relationship between dashboards and charts
-        existing_relationships = db.session.execute(
-            select([dashboard_slices.c.dashboard_id, 
dashboard_slices.c.slice_id])
-        ).fetchall()
-
         # import dashboards
         dashboards: list[Dashboard] = []
-        dashboard_chart_ids: list[tuple[int, int]] = []
         for file_name, config in configs.items():
             if file_name.startswith("dashboards/"):
                 config = update_id_refs(config, chart_ids, dataset_info)
                 dashboard = import_dashboard(config, overwrite=overwrite)
                 dashboards.append(dashboard)
+
+                # set ref in the dashboard_slices table
+                dashboard_chart_ids: list[dict[str, int]] = []
                 for uuid in find_chart_uuids(config["position"]):
                     if uuid not in chart_ids:
                         break

Review Comment:
   ### Premature Loop Break on Missing Chart UUID <sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The code prematurely breaks the chart association loop when encountering an 
unknown chart UUID, potentially missing valid chart associations that come 
after.
   
   ###### Why this matters
   If a single chart UUID is not found, all subsequent valid chart associations 
for the dashboard will be lost, leading to incomplete dashboard-chart 
relationships.
   
   ###### Suggested change ∙ *Feature Preview*
   Replace the break with continue to skip only the invalid chart UUID:
   ```python
   if uuid not in chart_ids:
       continue
   ```
   
   
   </details>
   
   ###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help 
Korbit improve your reviews.
   
   <!--- korbi internal id:01209fb2-0143-4305-a9e3-b00260d1db4f -->
   



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