mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 03:33:48 +00:00
ifcedit: fix Optional[entity_instance] coercion crash on native JSON values
coerce_value assumed value_str was always a CLI string, but ifcmcp passes JSON-decoded native types (int, None) straight through. Guard the Union/Optional "none" check so it only calls .lower() on strings, and handle native None explicitly.
This commit is contained in:
@@ -57,6 +57,16 @@ class TestOptionalCoercion:
|
||||
def test_optional_int(self):
|
||||
assert coerce_value("42", Optional[int]) == 42
|
||||
|
||||
def test_optional_entity_native_int(self, model):
|
||||
# MCP callers pass JSON-decoded native types (int), not CLI strings.
|
||||
wall = model.by_type("IfcWall")[0]
|
||||
result = coerce_value(wall.id(), Optional[ifcopenshell.entity_instance], model)
|
||||
assert result == wall
|
||||
|
||||
def test_optional_entity_native_none(self, model):
|
||||
# JSON null decodes to Python None, not the string "none".
|
||||
assert coerce_value(None, Optional[ifcopenshell.entity_instance], model) is None
|
||||
|
||||
|
||||
class TestUnionCoercion:
|
||||
def test_union_str_int(self):
|
||||
|
||||
Reference in New Issue
Block a user