bito-code-review[bot] commented on code in PR #36063:
URL: https://github.com/apache/superset/pull/36063#discussion_r2512406382


##########
superset/mcp_service/system/tool/get_instance_info.py:
##########
@@ -21,189 +21,27 @@
 """
 
 import logging
-from typing import Any, Dict
 
 from fastmcp import Context
 
 from superset.mcp_service.app import mcp
 from superset.mcp_service.auth import mcp_auth_hook
 from superset.mcp_service.mcp_core import InstanceInfoCore
 from superset.mcp_service.system.schemas import (
-    DashboardBreakdown,
-    DatabaseBreakdown,
     GetSupersetInstanceInfoRequest,
     InstanceInfo,
-    InstanceSummary,
-    PopularContent,
-    RecentActivity,
+)
+from superset.mcp_service.system.system_utils import (

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Import path not updated after function move</b></div>
   <div id="fix">
   
   The calculate functions have been moved to `system_utils`, but the import in 
`instance_metadata.py` still references the old location in 
`get_instance_info`, which will cause an ImportError when the instance metadata 
resource is accessed. This breaks production functionality for users trying to 
retrieve instance metadata. The fix updates the import path in 
`instance_metadata.py` to point to the new `system_utils` module.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    -        from superset.mcp_service.system.tool.get_instance_info import (
    -            calculate_dashboard_breakdown,
    -            calculate_database_breakdown,
    -            calculate_instance_summary,
    -            calculate_popular_content,
    -            calculate_recent_activity,
    -        )
    +        from superset.mcp_service.system.system_utils import (
    +            calculate_dashboard_breakdown,
    +            calculate_database_breakdown,
    +            calculate_instance_summary,
    +            calculate_popular_content,
    +            calculate_recent_activity,
    +        )
   ```
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/36063#issuecomment-3514443151>#1cb20f</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
tests/unit_tests/mcp_service/system/tool/test_health_check.py:
##########
@@ -0,0 +1,81 @@
+# 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.
+
+"""Tests for health_check MCP tool."""
+
+import pytest
+from pydantic import ValidationError
+
+from superset.mcp_service.system.schemas import (
+    GetHealthCheckRequest,
+    HealthCheckResponse,
+)
+
+
+def test_health_check_request_schema():
+    """Test that GetHealthCheckRequest schema allows empty object."""
+    # This should not raise validation errors
+    request = GetHealthCheckRequest()
+
+    # Verify it's a valid schema with no required fields
+    assert request is not None
+
+    # Verify it can be created from empty dict (simulating MCP client)
+    request_from_dict = GetHealthCheckRequest.model_validate({})
+    assert request_from_dict is not None
+
+
+def test_health_check_request_forbids_extra_fields():
+    """Test that GetHealthCheckRequest forbids unexpected fields."""
+    # Should raise validation error when extra fields are provided
+    with pytest.raises(ValidationError, match="extra.*forbidden|unexpected"):

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Fix incorrect ValidationError match pattern</b></div>
   <div id="fix">
   
   The pytest.raises match pattern 'extra.*forbidden|unexpected' does not match 
the actual Pydantic v2 ValidationError message 'Extra inputs are not permitted' 
for extra forbidden fields. This causes the test to fail to properly validate 
that GetHealthCheckRequest forbids unexpected fields, potentially allowing 
incorrect behavior to pass unnoticed. Update the match to 'Extra inputs are not 
permitted' to correctly catch the validation error.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       with pytest.raises(ValidationError, match="Extra inputs are not 
permitted"):
   ````
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/36063#issuecomment-3514443151>#1cb20f</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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