From df74e138a15ff2ce45fd375708fb96b69c97283d Mon Sep 17 00:00:00 2001 From: Clemens Vasters Date: Mon, 4 Mar 2024 19:48:32 +0100 Subject: [PATCH] recursion limit adjustment Signed-off-by: Clemens Vasters --- avrotize/common.py | 11 ++++++----- test/test_jsontoavro.py | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/avrotize/common.py b/avrotize/common.py index 63c3bca..38dd680 100644 --- a/avrotize/common.py +++ b/avrotize/common.py @@ -45,8 +45,8 @@ def find_schema_node(test, avro_schema, recursion_stack = []): for recursion_item in recursion_stack: if avro_schema is recursion_item: raise ValueError('Cyclical reference detected in schema') - if len(recursion_stack) > 30: - raise ValueError('Maximum recursion depth 30 exceeded in schema') + if len(recursion_stack) > 50: + raise ValueError('Maximum recursion depth 50 exceeded in schema') try: recursion_stack.append(avro_schema) if isinstance(avro_schema, dict): @@ -60,9 +60,10 @@ def find_schema_node(test, avro_schema, recursion_stack = []): return node elif isinstance(avro_schema, list): for item in avro_schema: - node = find_schema_node(test, item, recursion_stack) - if node: - return node + if isinstance(item, (dict,list)): + node = find_schema_node(test, item, recursion_stack) + if node: + return node return None finally: recursion_stack.pop() diff --git a/test/test_jsontoavro.py b/test/test_jsontoavro.py index 6c53d5a..21b3334 100644 --- a/test/test_jsontoavro.py +++ b/test/test_jsontoavro.py @@ -102,7 +102,6 @@ def test_convert_avro_avsc_jsons_to_avro(self): def test_convert_clouidify_jsons_to_avro(self): self.create_avro_from_jsons("cloudify.json", "cloudify.avsc") - @pytest.mark.skip(reason="Recursion issue") def test_convert_databricks_asset_bundles_to_avro(self): self.create_avro_from_jsons("databricks-asset-bundles.json", "databricks-asset-bundles.avsc")