codeant-ai-for-open-source[bot] commented on code in PR #41200:
URL: https://github.com/apache/superset/pull/41200#discussion_r3436751279


##########
superset/models/slice.py:
##########
@@ -82,6 +82,7 @@ class Slice(  # pylint: disable=too-many-public-methods
     viz_type = Column(String(250))
     params = Column(utils.MediumText())
     query_context = Column(utils.MediumText())
+    extra = Column(utils.MediumText())

Review Comment:
   **Suggestion:** The new chart metadata field is persisted on the model but 
not copied when charts are cloned, so dashboard duplication will silently drop 
`extra` metadata on the duplicated charts. Update the chart cloning path to 
include this new field so cloned charts preserve the same metadata as the 
source chart. [incomplete implementation]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Dashboard copy with duplicate charts drops chart extra metadata.
   - ⚠️ Cloned charts diverge from originals in stored configuration.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. In a running Superset instance with this PR applied, pick an existing 
dashboard with
   charts and ensure at least one chart has `Slice.extra` set (e.g. via a shell 
or test
   fixture): `original_slc.extra = '{"foo": "bar"}'` for a `Slice` instance 
attached to a
   dashboard. The `Slice` model (including the new `extra` column) is defined in
   `superset/models/slice.py:17-27` as seen in the class definition.
   
   2. Trigger a dashboard copy operation with chart duplication enabled. In 
production this
   is done via the dashboard copy API which uses `CopyDashboardCommand`
   (`superset/commands/dashboard/copy.py:6-15`) and 
`DashboardDAO.copy_dashboard`. In tests
   the same path is exercised directly in
   `superset/tests/integration_tests/dashboards/dao_tests.py:27-42`, where
   `DashboardDAO.copy_dashboard(original_dash, dash_data)` is called with
   `dash_data["duplicate_slices"] = True`.
   
   3. During the copy operation, `DashboardDAO.copy_dashboard` in
   `superset/daos/dashboard.py:368-46` iterates over `original_dash.slices` 
and, when
   `duplicate_slices` is true, calls `new_slice = slc.clone()` at line 386 for 
each chart,
   then adds each `new_slice` to the session and associates it with the new 
dashboard.
   
   4. The `Slice.clone` method in `superset/models/slice.py:151-42` constructs 
a new `Slice`
   with only `slice_name`, `datasource_id`, `datasource_type`, 
`datasource_name`, `viz_type`,
   `params`, `description`, and `cache_timeout`, and does not copy the `extra` 
field. As a
   result, each cloned chart's `extra` column remains NULL/empty even though 
the source
   chart's `extra` contained metadata, so the duplicated dashboard's charts 
silently lose
   their `extra` metadata.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=984bb79acd46453aa6906d294073207c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=984bb79acd46453aa6906d294073207c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/models/slice.py
   **Line:** 85:85
   **Comment:**
        *Incomplete Implementation: The new chart metadata field is persisted 
on the model but not copied when charts are cloned, so dashboard duplication 
will silently drop `extra` metadata on the duplicated charts. Update the chart 
cloning path to include this new field so cloned charts preserve the same 
metadata as the source chart.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41200&comment_hash=ea1edd6092344ea144f54567426c5d3b0ff7195f65e8d78842da24a2b3c4923d&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41200&comment_hash=ea1edd6092344ea144f54567426c5d3b0ff7195f65e8d78842da24a2b3c4923d&reaction=dislike'>👎</a>



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