From 40106e4765458db9952684b68dfca307e6df0d56 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Wed, 26 Nov 2025 10:52:50 -0300 Subject: [PATCH] feat: validates that top level type cannot be list --- jambo/schema_converter.py | 5 ++--- tests/test_schema_converter.py | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/jambo/schema_converter.py b/jambo/schema_converter.py index c2c8cae..3a93bc6 100644 --- a/jambo/schema_converter.py +++ b/jambo/schema_converter.py @@ -138,9 +138,8 @@ class SchemaConverter: type_value = schema.get("type") if isinstance(type_value, list): - raise InternalAssertionException( - "SchemaConverter._get_schema_type: 'type' field should not be a list here." - " This should have been normalized earlier." + raise InvalidSchemaException( + "Invalid schema: 'type' cannot be a list at the top level", invalid_field=str(schema) ) return type_value diff --git a/tests/test_schema_converter.py b/tests/test_schema_converter.py index 01c18be..3bfe327 100644 --- a/tests/test_schema_converter.py +++ b/tests/test_schema_converter.py @@ -1045,5 +1045,14 @@ class TestSchemaConverter(TestCase): }, } + with self.assertRaises(InvalidSchemaException): + self.converter.build_with_cache(schema) + + def test_parse_list_type_root_level_throws(self): + schema = { + "title": "TestListType", + "type": ["string", "number"] + } + with self.assertRaises(InvalidSchemaException): self.converter.build_with_cache(schema) \ No newline at end of file