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


##########
tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py:
##########
@@ -134,6 +136,23 @@ async def test_list_dashboards_basic(mock_list, 
mcp_server):
         assert "slug" in data["columns_loaded"]
 
 
+def test_dashboard_role_serializer_serializes_permission_view_names():

Review Comment:
   **Suggestion:** Add an explicit return type annotation (`-> None`) to this 
new test function so it is fully typed. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python test function in the modified hunk and it has 
no parameter or return type annotations. The custom rule requires new Python 
code to be fully typed, so the suggestion accurately identifies a real 
violation.
   </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=074f224a0d704774b867800eaa610434&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=074f224a0d704774b867800eaa610434&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:** tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
   **Line:** 139:139
   **Comment:**
        *Custom Rule: Add an explicit return type annotation (`-> None`) to 
this new test function so it is fully typed.
   
   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%2F41404&comment_hash=b586f100ad5a6b7a920c95d7056d74eee4f0bd7d22fc06e73be64e399d9db81a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41404&comment_hash=b586f100ad5a6b7a920c95d7056d74eee4f0bd7d22fc06e73be64e399d9db81a&reaction=dislike'>👎</a>



##########
superset/mcp_service/dashboard/schemas.py:
##########
@@ -152,15 +153,41 @@ def serialize_role_object(role: Any) -> RoleInfo | None:
     if not role:
         return None
 
+    try:
+        raw_permissions = getattr(role, "permissions", None)
+    except DetachedInstanceError:
+        raw_permissions = None
+
+    permissions: list[str] | None = None
+    if raw_permissions is not None:
+        permissions = []
+        try:
+            for permission in raw_permissions:
+                permission_name = _serialize_permission_name(permission)
+                if permission_name is not None:
+                    permissions.append(permission_name)
+        except (DetachedInstanceError, TypeError):
+            permissions = []
+
     return RoleInfo(
         id=getattr(role, "id", None),
         name=getattr(role, "name", None),
-        permissions=[perm.name for perm in getattr(role, "permissions", [])]
-        if hasattr(role, "permissions")
-        else None,
+        permissions=permissions,
     )
 
 
+def _serialize_permission_name(permission: Any) -> str | None:
+    if (name := getattr(permission, "name", None)) is not None:
+        return str(name)
+
+    permission_name = getattr(getattr(permission, "permission", None), "name", 
None)
+    view_menu_name = getattr(getattr(permission, "view_menu", None), "name", 
None)
+    if permission_name and view_menu_name:
+        return f"{permission_name} on {view_menu_name}"
+
+    return None

Review Comment:
   **Suggestion:** Add a short docstring to this newly introduced helper 
function describing how permission names are derived and when `None` is 
returned. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python function and it has no docstring in the final 
file state.
   The custom rule explicitly requires new functions and classes to be 
documented inline, so
   the suggestion correctly identifies a real rule violation.
   </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=618d07f3ee3e4508949d59b33036ca62&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=618d07f3ee3e4508949d59b33036ca62&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/mcp_service/dashboard/schemas.py
   **Line:** 179:188
   **Comment:**
        *Custom Rule: Add a short docstring to this newly introduced helper 
function describing how permission names are derived and when `None` is 
returned.
   
   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%2F41404&comment_hash=4704f006ea885f2548bfb05388530db1b84255d83d02a83e3d316b79f3104811&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41404&comment_hash=4704f006ea885f2548bfb05388530db1b84255d83d02a83e3d316b79f3104811&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