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


##########
superset/commands/dashboard/filter_state/get.py:
##########
@@ -40,3 +42,48 @@ def get(self, cmd_params: CommandParameters) -> 
Optional[str]:
         if entry and self._refresh_timeout:
             cache_manager.filter_state_cache.set(key, entry)
         return entry.get("value")
+
+    @staticmethod
+    def get_filter_names(resource_id: int, value: Optional[str]) -> dict[str, 
str]:
+        """
+        Cross-reference the filter ids present in a cached filter_state
+        ``value`` (a ``DataMaskStateWithId``, i.e. a map keyed by filter id)
+        against the dashboard's ``native_filter_configuration`` to build a
+        map of filter id -> human-readable filter label.
+
+        The cached blob itself has no notion of a filter's label: that only
+        lives in the dashboard's filter configuration metadata (#36053).
+        """
+        if not value:
+            return {}
+        try:
+            parsed_value = json.loads(value)
+        except (json.JSONDecodeError, TypeError):
+            return {}
+        if not isinstance(parsed_value, dict):
+            return {}
+
+        dashboard = DashboardDAO.get_by_id_or_slug(str(resource_id))
+        try:
+            metadata = json.loads(dashboard.json_metadata or "{}")
+        except (json.JSONDecodeError, TypeError):
+            return {}
+        if not isinstance(metadata, dict):
+            return {}
+
+        native_filters: list[dict[str, Any]] = metadata.get(
+            "native_filter_configuration", []
+        )
+        id_to_name = {
+            native_filter["id"]: native_filter["name"]
+            for native_filter in native_filters

Review Comment:
   **Suggestion:** `native_filter_configuration` is allowed to be null, but 
iterating it raises `TypeError`, causing GET requests for such dashboards to 
fail instead of returning an empty names map. [null pointer]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![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=ef8e8d5aa6dc4780b3f8c0f2aa684940&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=ef8e8d5aa6dc4780b3f8c0f2aa684940&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/commands/dashboard/filter_state/get.py
   **Line:** 74:79
   **Comment:**
        *Null Pointer: `native_filter_configuration` is allowed to be null, but 
iterating it raises `TypeError`, causing GET requests for such dashboards to 
fail instead of returning an empty names map.
   
   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%2F44043&comment_hash=42cdd450ab031761ec98a924938d093195fbda4925ca4a0ed316c074a0efbea1&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44043&comment_hash=42cdd450ab031761ec98a924938d093195fbda4925ca4a0ed316c074a0efbea1&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