Skip to content

Commit 1e4f31a

Browse files
committed
fix(manage_gameobject): validate parsed component_properties is a dict; return clear error
1 parent 5151677 commit 1e4f31a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

MCPForUnity/UnityMcpServer~/src/tools/manage_gameobject.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@ def _to_vec3(parts):
119119
try:
120120
component_properties = json.loads(component_properties)
121121
ctx.info("manage_gameobject: coerced component_properties from JSON string to dict")
122-
except Exception as e:
123-
ctx.warn(f"manage_gameobject: failed to parse component_properties JSON string: {e}")
122+
except json.JSONDecodeError as e:
123+
return {"success": False, "message": f"Invalid JSON in component_properties: {e}"}
124+
# Ensure final type is a dict (object) if provided
125+
if component_properties is not None and not isinstance(component_properties, dict):
126+
return {"success": False, "message": "component_properties must be a JSON object (dict)."}
124127
try:
125128
# Map tag to search_term when search_method is by_tag for backward compatibility
126129
if action == "find" and search_method == "by_tag" and tag is not None and search_term is None:

0 commit comments

Comments
 (0)