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


##########
superset/commands/dashboard/update.py:
##########
@@ -83,11 +83,23 @@ def run(self) -> Model:
                     json.loads(position_json)
                 )
 
-            dashboard = DashboardDAO.update(self._model, self._properties)
-            if self._properties.get("json_metadata"):
+            # ``set_dash_metadata`` merges the incoming metadata against
+            # ``dashboard.params_dict`` (the *stored* ``json_metadata``) to
+            # preserve fields the caller omitted. Routing ``json_metadata``
+            # through the generic attribute update below would overwrite
+            # that stored value before the merge ever sees it, silently
+            # collapsing the merge into a no-op and resetting any omitted
+            # field to its default -- so it is excluded here and applied
+            # exclusively via ``set_dash_metadata``.
+            json_metadata = self._properties.get("json_metadata")
+            dashboard = DashboardDAO.update(
+                self._model,
+                {k: v for k, v in self._properties.items() if k != 
"json_metadata"},
+            )
+            if json_metadata:
                 DashboardDAO.set_dash_metadata(
                     dashboard,
-                    data=json.loads(self._properties.get("json_metadata", 
"{}")),
+                    data=json.loads(json_metadata),
                 )

Review Comment:
   **Suggestion:** The generic update now excludes `json_metadata`, but this 
branch only invokes `set_dash_metadata` for truthy values. Because 
`DashboardPutSchema` permits `json_metadata` to be `None` or an empty string, 
an explicit request to clear the metadata is silently ignored and the previous 
stored JSON remains unchanged. Distinguish an omitted key from an explicit 
null/empty value and preserve the prior clearing behavior. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ REST clients cannot explicitly clear dashboard JSON metadata.
   - ⚠️ Dashboard cleanup requests silently report success while retaining 
stale metadata.
   - ⚠️ Properties and API update behavior diverge for null or empty 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=676b6c9a0be246e6ad8661aa65384455&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=676b6c9a0be246e6ad8661aa65384455&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/commands/dashboard/update.py
   **Line:** 94:103
   **Comment:**
        *Api Mismatch: The generic update now excludes `json_metadata`, but 
this branch only invokes `set_dash_metadata` for truthy values. Because 
`DashboardPutSchema` permits `json_metadata` to be `None` or an empty string, 
an explicit request to clear the metadata is silently ignored and the previous 
stored JSON remains unchanged. Distinguish an omitted key from an explicit 
null/empty value and preserve the prior clearing behavior.
   
   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%2F42142&comment_hash=6ae8ea3df1c310522c4143e05260726a27376411657023e22e9879be2e65451c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42142&comment_hash=6ae8ea3df1c310522c4143e05260726a27376411657023e22e9879be2e65451c&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