From a0c854ded21abaa45e9bf55c984cfad894d96d43 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Thu, 29 Aug 2024 09:48:00 -0700 Subject: [PATCH] Ignore unknown metadata and shape keys (#3095) --- .../lib/aws-sdk-code-generator.rb | 9 +++++++++ .../views/client_api_module.rb | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator.rb index 49425146ebe..139a6d34548 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator.rb @@ -103,4 +103,13 @@ module AwsSdkCodeGenerator # WARNING ABOUT GENERATED CODE WARNING_TXT + @warnings = [] + + class << self + attr_reader :warnings + def warn(service, type, message) + Kernel.warn(message) + @warnings << { service: service, type: type, message: message } + end + end end diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/client_api_module.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/client_api_module.rb index 452fd4c0924..fed3e51e3c6 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/client_api_module.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/client_api_module.rb @@ -192,7 +192,11 @@ def metadata value: @service.api['metadata'][key].inspect } elsif METADATA_KEYS[key].nil? - raise "unhandled metadata key #{key.inspect}" + AwsSdkCodeGenerator.warn( + @service.service_id, + :invalid_key, + "unhandled metadata key `#{key}`" + ) end end metadata @@ -317,7 +321,11 @@ def shape_constructor_args(shape_name, shape) args << "#{key}: #{value.inspect}" elsif SHAPE_KEYS[key].nil? - raise "unhandled shape key #{key.inspect}" + AwsSdkCodeGenerator.warn( + @service.service_id, + :invalid_key, + "unhandled shape key `#{key}` on `#{shape_name}`" + ) end end args.join(', ')