diff --git a/src/agent_toolkit/forestadmin/agent_toolkit/utils/forest_schema/action_values.py b/src/agent_toolkit/forestadmin/agent_toolkit/utils/forest_schema/action_values.py index 363ee2302..cf0c25594 100644 --- a/src/agent_toolkit/forestadmin/agent_toolkit/utils/forest_schema/action_values.py +++ b/src/agent_toolkit/forestadmin/agent_toolkit/utils/forest_schema/action_values.py @@ -101,7 +101,7 @@ def value_to_forest(field: ActionField, value: Any) -> Any: elif field["type"] == ActionFieldType.COLLECTION and value: value = cast(CompositeIdAlias, value) - return "|".join(value) + return "|".join([str(v) for v in value]) elif field["type"] == ActionFieldType.FILE and value: return ForestValueConverter._make_data_uri(value) diff --git a/src/agent_toolkit/tests/utils/forest_schema/test_action_values.py b/src/agent_toolkit/tests/utils/forest_schema/test_action_values.py index 29a8b2259..26541538b 100644 --- a/src/agent_toolkit/tests/utils/forest_schema/test_action_values.py +++ b/src/agent_toolkit/tests/utils/forest_schema/test_action_values.py @@ -156,6 +156,30 @@ def test_should_transform_multi_pk_into_composite(self): "1|2", ) + def test_should_parse_correctly_pks_when_they_are_integer(self): + self.assertEqual( + ForestValueConverter.value_to_forest( + { + "type": ActionFieldType.COLLECTION, + "watch_changes": False, + "label": "test_enum", + }, + [1], + ), + "1", + ) + self.assertEqual( + ForestValueConverter.value_to_forest( + { + "type": ActionFieldType.COLLECTION, + "watch_changes": False, + "label": "test_enum", + }, + [1, 2], + ), + "1|2", + ) + def test_should_transform_file_into_datauri(self): self.assertEqual( ForestValueConverter.value_to_forest(