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


##########
superset/subjects/api.py:
##########
@@ -19,7 +19,7 @@
 from flask_appbuilder.models.sqla.interface import SQLAInterface
 
 from superset.constants import RouteMethod
-from superset.subjects.filters import SubjectAllTextFilter
+from superset.subjects.filters import SubjectAllTextFilter, SubjectListFilter

Review Comment:
   **Suggestion:** The newly added `SubjectAllTextFilter` import is never 
referenced in this file. This triggers the repository's unused-import lint 
check and should be removed unless it is intended to be used by the API 
configuration. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - โŒ Repository lint checks can fail on `superset/subjects/api.py`.
   - โš ๏ธ Subject API runtime behavior is otherwise unaffected.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction โœ… </b></summary>
   
   ```mdx
   1. Run the repository's Python lint or unused-import checks against
   `superset/subjects/api.py`.
   
   2. The checker parses line 22, where both `SubjectAllTextFilter` and 
`SubjectListFilter`
   are imported.
   
   3. `SubjectListFilter` is referenced by `base_filters` at 
`superset/subjects/api.py:55`,
   but no reference to `SubjectAllTextFilter` exists in this file.
   
   4. Observe an unused-import diagnostic for `SubjectAllTextFilter`; removing 
it leaves the
   subject API configuration unchanged.
   ```
   </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=1bd020b83fd7400c9d4a727cf666f671&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=1bd020b83fd7400c9d4a727cf666f671&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/subjects/api.py
   **Line:** 22:22
   **Comment:**
        *Possible Bug: The newly added `SubjectAllTextFilter` import is never 
referenced in this file. This triggers the repository's unused-import lint 
check and should be removed unless it is intended to be used by the API 
configuration.
   
   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%2F42472&comment_hash=15cfeaf4f7088971f7641ce59956b80c88660f421ac45119f02ccc0e011ceb0d&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42472&comment_hash=15cfeaf4f7088971f7641ce59956b80c88660f421ac45119f02ccc0e011ceb0d&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/commands/chart/importers/v1/utils.py:
##########
@@ -201,12 +203,29 @@ def import_chart(
     if chart.id is None:
         db.session.flush()
 
-    if user:
-        from superset.subjects.utils import get_user_subject
+    # Only newly created charts inherit the creator's editor/viewer defaults;
+    # re-importing over an existing chart (overwrite or soft-delete restore)
+    # must not silently grant the importer's groups access. Mirrors the
+    # dashboard importer's ``not existing`` guard.
+    if not existing and user:
+        from superset.subjects.utils import (
+            get_default_viewers_for_new_asset,
+            get_user_subject,
+        )
 
         subj = get_user_subject(user.id)
         if subj and subj not in chart.editors:
             chart.editors.append(subj)
+        # Resolved once by bulk importers and passed in; recomputed here only
+        # for direct callers that omit it (one membership query per asset).
+        viewers = (
+            default_viewers
+            if default_viewers is not None
+            else get_default_viewers_for_new_asset(user.id)
+        )
+        for viewer in viewers:
+            if viewer not in chart.viewers:
+                chart.viewers.append(viewer)

Review Comment:
   โœ… **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag appending default viewers as overriding explicit viewers in v1 
chart imports; v1 payloads do not contain or import a viewers field.
   
   **Applied to:**
     - `superset/commands/chart/importers/v1/utils.py`
   
   ---
   ๐Ÿ’ก *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



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