From 332438056550ecc00b9b8a4bbc5acf2f4bf210c8 Mon Sep 17 00:00:00 2001 From: patrzhan <139926810+patrzhan@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:45:04 -0800 Subject: [PATCH] refactor: consolidate similar error messages about invalid recipes (#263) --- .../component/transformer/PublishRecipeTransformer.py | 4 ++-- gdk/common/exceptions/error_messages.py | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/gdk/commands/component/transformer/PublishRecipeTransformer.py b/gdk/commands/component/transformer/PublishRecipeTransformer.py index 80bdc874..be5595d2 100644 --- a/gdk/commands/component/transformer/PublishRecipeTransformer.py +++ b/gdk/commands/component/transformer/PublishRecipeTransformer.py @@ -7,7 +7,7 @@ import gdk.common.consts as consts import gdk.common.utils as utils -from gdk.common.exceptions.error_messages import BUILT_RECIPE_SIZE_INVALID, BUILD_RECIPE_FILE_INVALID, SCHEMA_FILE_INVALID +from gdk.common.exceptions.error_messages import BUILT_RECIPE_SIZE_INVALID, PROJECT_RECIPE_FILE_INVALID, SCHEMA_FILE_INVALID class PublishRecipeTransformer: @@ -103,6 +103,6 @@ def create_publish_recipe_file(self, parsed_component_recipe) -> None: validator = RecipeValidator(recipe_schema_path) validator.validate_recipe(parsed_component_recipe.to_dict()) except jsonschema.exceptions.ValidationError as err: - raise Exception(BUILD_RECIPE_FILE_INVALID.format(recipe_path, err.message)) + raise Exception(PROJECT_RECIPE_FILE_INVALID.format(recipe_path, err.message)) except jsonschema.exceptions.SchemaError as err: raise Exception(SCHEMA_FILE_INVALID.format(err.message)) diff --git a/gdk/common/exceptions/error_messages.py b/gdk/common/exceptions/error_messages.py index 0206b94f..8d96ec39 100644 --- a/gdk/common/exceptions/error_messages.py +++ b/gdk/common/exceptions/error_messages.py @@ -16,11 +16,6 @@ "The Greengrass recipe schema file has an unexpected error.\nPlease report it at " + "https://github.com/aws-greengrass/aws-greengrass-gdk-cli/issues if the issue persists.\nError details: {} " ) -BUILD_RECIPE_FILE_INVALID = ( - "Built recipe file '{}' is invalid. Please correct its format and try again.\nFor more information regarding " + - "component recipes refer to the docs here: https://docs.aws.amazon.com/greengrass/v2/developerguide/" + - "component-recipe-reference.html\nError: {} " -) CLI_MODEL_FILE_NOT_EXISTS = "Model validation failed. CLI model file doesn't exist." RECIPE_SIZE_INVALID = ( "The input recipe file '{}' has an invalid size of {} bytes. Please make sure it does not exceed 16kB"