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


##########
superset/commands/dataset/export.py:
##########
@@ -103,32 +107,41 @@ def _export(
             )
             file_path = f"databases/{db_file_name}.yaml"
 
-            payload = model.database.export_to_dict(
-                recursive=False,
-                include_parent_ref=False,
-                include_defaults=True,
-                export_uuids=True,
-            )
-            # TODO (betodealmeida): move this logic to export_to_dict once this
-            # becomes the default export endpoint
-            if payload.get("extra"):
-                try:
-                    payload["extra"] = json.loads(payload["extra"])
-                except json.JSONDecodeError:
-                    logger.info("Unable to decode `extra` field: %s", 
payload["extra"])
-
-            if ssh_tunnel := model.database.ssh_tunnel:
-                ssh_tunnel_payload = ssh_tunnel.export_to_dict(
+            # Only yield the database file if not already seen. This is
+            # critical to fix the issue where databases were being
+            # duplicated and potentially overwritten when charts from
+            # different databases were exported.
+            if file_path not in seen:

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing seen-set update</b></div>
   <div id="fix">
   
   After yielding the database file, `file_path` must be added to the `seen` 
set to prevent duplicate yields. Currently the `if file_path not in seen:` 
check will always pass on subsequent calls, causing the same database file to 
be yielded multiple times instead of being deduplicated.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #7add1b</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