From 6e7fb41c15ebba3b8f6b766bb693b4d8db7d6d04 Mon Sep 17 00:00:00 2001 From: ihsan Date: Wed, 22 Oct 2025 11:24:36 +0300 Subject: [PATCH 1/4] Fail the generator if any type mapping in any language is missing. Do not suppress and continue. --- cpp/__init__.py | 19 ++++++++++++------- cs/__init__.py | 1 - util.py | 10 +++++++--- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cpp/__init__.py b/cpp/__init__.py index 373cd458..b58d9e3d 100644 --- a/cpp/__init__.py +++ b/cpp/__init__.py @@ -40,9 +40,12 @@ def cpp_types_encode(key): try: cpp_type = _cpp_types_encode[key] except KeyError: - cpp_type = _cpp_types_common[key] - if cpp_type == "NA": - raise NotImplementedError("Missing type Mapping for " + key) + try: + cpp_type = _cpp_types_common[key] + except KeyError: + cpp_type = None + if cpp_type is None or cpp_type == "NA": + raise NotImplementedError("Missing type Mapping for [" + key + "]") return cpp_type @@ -50,9 +53,12 @@ def cpp_types_decode(key): try: cpp_type = _cpp_types_decode[key] except KeyError: - cpp_type = _cpp_types_common[key] - if cpp_type == "NA": - raise NotImplementedError("Missing type Mapping for " + key) + try: + cpp_type = _cpp_types_common[key] + except KeyError: + cpp_type = None + if cpp_type is None or cpp_type == "NA": + raise NotImplementedError("Missing type Mapping for [" + key + "]") return cpp_type @@ -180,7 +186,6 @@ def cpp_escape_keyword(value): "Schema": "serialization::pimpl::schema", "List_Schema": "std::vector", - "Version": "version", } _cpp_types_encode = { diff --git a/cs/__init__.py b/cs/__init__.py index 8fc550bf..d1cd5bc1 100644 --- a/cs/__init__.py +++ b/cs/__init__.py @@ -36,7 +36,6 @@ def cs_types(key, d): try: cs_type = d[key] - cs_type = d[key] except KeyError: try: cs_type = _cs_types_common[key] diff --git a/util.py b/util.py index 1172ba52..e475a22c 100644 --- a/util.py +++ b/util.py @@ -263,7 +263,10 @@ def generate_codecs(services, custom_services, template, output_dir, lang, env): ) save_file(join(output_dir, codec_file_name), content) except NotImplementedError as e: - print("[%s] contains missing type mapping so ignoring it. Error: %s" % (codec_file_name, e)) + raise NotImplementedError( + "[%s.%s] codec contains missing type mapping for %s language. %s" % (service_name, + method_name, lang.value, + e)) if lang is SupportedLanguages.CPP: content = get_rendered_text("footer.j2", env) @@ -302,8 +305,9 @@ def generate_custom_codecs(services, template, output_dir, lang, env): content = template.render(codec=codec) save_file(join(output_dir, codec_file_name), content) except NotImplementedError as e: - print("[%s] contains missing type mapping so ignoring it. Error: %s" % (codec_file_name, e)) - + raise NotImplementedError( + "[%s] codec contains missing type mapping for %s language. %s" % (codec["name"], + lang.value, e)) def generate_documentation(services, custom_definitions, template, output_dir): makedirs(output_dir, exist_ok=True) From ed0722f48a5806b982c2d17fe9c0f7e4d18426de Mon Sep 17 00:00:00 2001 From: ihsan demir Date: Wed, 22 Oct 2025 11:39:01 +0300 Subject: [PATCH 2/4] Update util.py Co-authored-by: Jack Green --- util.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/util.py b/util.py index e475a22c..573ec92b 100644 --- a/util.py +++ b/util.py @@ -264,9 +264,7 @@ def generate_codecs(services, custom_services, template, output_dir, lang, env): save_file(join(output_dir, codec_file_name), content) except NotImplementedError as e: raise NotImplementedError( - "[%s.%s] codec contains missing type mapping for %s language. %s" % (service_name, - method_name, lang.value, - e)) + f"[{service_name}.{method_name}] codec contains missing type mapping for {lang.value} language. {e}") if lang is SupportedLanguages.CPP: content = get_rendered_text("footer.j2", env) From ce2f44159d7e367384f33f9e0b1fd9041999dcc1 Mon Sep 17 00:00:00 2001 From: ihsan demir Date: Wed, 22 Oct 2025 11:39:53 +0300 Subject: [PATCH 3/4] Update util.py Co-authored-by: Jack Green --- util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util.py b/util.py index 573ec92b..8ad83df9 100644 --- a/util.py +++ b/util.py @@ -304,8 +304,7 @@ def generate_custom_codecs(services, template, output_dir, lang, env): save_file(join(output_dir, codec_file_name), content) except NotImplementedError as e: raise NotImplementedError( - "[%s] codec contains missing type mapping for %s language. %s" % (codec["name"], - lang.value, e)) + f"[{codec['name']}] codec contains missing type mapping for {lang.value} language. {e}") def generate_documentation(services, custom_definitions, template, output_dir): makedirs(output_dir, exist_ok=True) From e3da5605dbc89e6f46454141c2d2e076ce1497b7 Mon Sep 17 00:00:00 2001 From: ihsan Date: Wed, 22 Oct 2025 11:41:50 +0300 Subject: [PATCH 4/4] Review comment fix. --- cpp/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/__init__.py b/cpp/__init__.py index b58d9e3d..56e1db7a 100644 --- a/cpp/__init__.py +++ b/cpp/__init__.py @@ -45,7 +45,7 @@ def cpp_types_encode(key): except KeyError: cpp_type = None if cpp_type is None or cpp_type == "NA": - raise NotImplementedError("Missing type Mapping for [" + key + "]") + raise NotImplementedError(f"Missing type Mapping for [{key}]") return cpp_type @@ -58,7 +58,7 @@ def cpp_types_decode(key): except KeyError: cpp_type = None if cpp_type is None or cpp_type == "NA": - raise NotImplementedError("Missing type Mapping for [" + key + "]") + raise NotImplementedError(f"Missing type Mapping for [{key}]") return cpp_type @@ -66,7 +66,7 @@ def get_size(type): try: size = _type_size[type] except KeyError: - raise NotImplementedError("Missing type size Mapping " + type) + raise NotImplementedError(f"Missing type size Mapping [{type}]") return size