codeant-ai-for-open-source[bot] commented on code in PR #40351: URL: https://github.com/apache/superset/pull/40351#discussion_r3326698976
########## superset/mcp_service/annotation_layer/tool/update_layer_annotation.py: ########## @@ -0,0 +1,153 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import logging +from typing import Any + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.annotation_layer.schemas import ( + UpdateLayerAnnotationRequest, + UpdateLayerAnnotationResponse, +) + +logger = logging.getLogger(__name__) + + +def _build_update_properties(request: UpdateLayerAnnotationRequest) -> dict[str, Any]: + """Build the properties dict for UpdateAnnotationCommand from the request.""" + properties: dict[str, Any] = {"layer": request.layer_id} + if request.short_descr is not None: + properties["short_descr"] = request.short_descr + if request.start_dttm is not None: + properties["start_dttm"] = request.start_dttm + if request.end_dttm is not None: + properties["end_dttm"] = request.end_dttm + if request.long_descr is not None: + properties["long_descr"] = request.long_descr + if request.json_metadata is not None: + properties["json_metadata"] = request.json_metadata Review Comment: **🟠Architect Review — HIGH** The update_layer_annotation MCP tool cannot clear nullable fields (long_descr, json_metadata): values of None are treated as "field not provided" and omitted from the UpdateAnnotationCommand payload, so clients have no way to set these columns back to NULL or empty as supported by the REST API. **Suggestion:** Track which fields were explicitly present in the request (e.g. via Pydantic's fields-set) and distinguish "omitted" from "explicitly null", forwarding explicit nulls or empty values for long_descr/json_metadata into UpdateAnnotationCommand so MCP updates can also clear these fields. [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d30471fbdb364453abca7a9ca2ed5983&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=d30471fbdb364453abca7a9ca2ed5983&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 an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood. **Path:** superset/mcp_service/annotation_layer/tool/update_layer_annotation.py **Line:** 42:45 **Comment:** *HIGH: The update_layer_annotation MCP tool cannot clear nullable fields (long_descr, json_metadata): values of None are treated as "field not provided" and omitted from the UpdateAnnotationCommand payload, so clients have no way to set these columns back to NULL or empty as supported by the REST API. 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. If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding. 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> -- 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]
