codeant-ai-for-open-source[bot] commented on code in PR #46048: URL: https://github.com/apache/superset/pull/46048#discussion_r4488185752
########## superset/mcp_service/dataset/tool/update_dataset_column.py: ########## @@ -0,0 +1,294 @@ +# 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. + +"""Update a column on a dataset (FastMCP tool).""" + +import difflib +from typing import Any + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset import security_manager +from superset.extensions import event_logger +from superset.mcp_service.dataset.schemas import ( + _calculated_expression, + DatasetColumnDetail, + PHYSICAL_COLUMN_LOCKED_FIELDS, + UpdateDatasetColumnRequest, + UpdateDatasetColumnResponse, +) + + +def _is_calculated(column: Any) -> bool: + """A calculated column is one defined by a non-blank SQL expression.""" + return _calculated_expression(column) is not None + + +def _find_column(columns: list[Any], identifier: int | str) -> Any | None: + """Find a dataset column by ID, UUID, or column_name.""" + if isinstance(identifier, str): + try: + identifier = int(identifier) + except ValueError: + pass + + if isinstance(identifier, int): + return next((c for c in columns if c.id == identifier), None) Review Comment: **Suggestion:** A JSON `true` can pass the `int | str` column field as integer 1; this branch then selects column ID 1 instead of rejecting the malformed identifier. **Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Type error` [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=eeef9d3b42194d02bc4a24be2a79a2af&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=eeef9d3b42194d02bc4a24be2a79a2af&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/mcp_service/dataset/tool/update_dataset_column.py **Line:** 50:51 **Comment:** *Type Error: A JSON `true` can pass the `int | str` column field as integer 1; this branch then selects column ID 1 instead of rejecting the malformed identifier. 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%2F46048&comment_hash=b2b45f7e33b6c1cd746c42d49167553c61b7975d0d23880dd1349c0d8e95db08&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46048&comment_hash=b2b45f7e33b6c1cd746c42d49167553c61b7975d0d23880dd1349c0d8e95db08&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]
