From 3b86f52b063da4e14d16b9bbb5aab5ceed8117ed Mon Sep 17 00:00:00 2001 From: Alex Mooney Date: Fri, 4 Apr 2025 13:26:03 -0700 Subject: [PATCH 1/2] Remove uuidtools but keep validation logic --- Gemfile | 1 - LICENSE-3rdparty.csv | 1 - datadog_api_client.gemspec | 2 -- lib/datadog_api_client/v2/model_base.rb | 6 ++++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 7671c0b5d171..beb1d2ec9adc 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,6 @@ group :development, :test do gem 'webmock' gem 'zstandard' gem 'pry' - gem 'uuidtools' end group :docs do diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 01f7f618e215..80f176adfd4c 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -71,7 +71,6 @@ tomlrb,MIT,Francois Bernier typhoeus,MIT,"David Balatero, Paul Dix, Hans Hasselberg" tzinfo,MIT,Philip Ross unicode-display_width,MIT,Jan Lelis -uuidtools,Apache-2.0,Bob Aman vcr,"Hippocratic-2.1,MIT","Myron Marston, Kurtis Rainbolt-Greene, Olle Jonsson" webmock,MIT,Bartosz Blimke with_env,MIT,Zach Dennis diff --git a/datadog_api_client.gemspec b/datadog_api_client.gemspec index 3557414e0e67..2945e9cd456b 100644 --- a/datadog_api_client.gemspec +++ b/datadog_api_client.gemspec @@ -26,8 +26,6 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "zeitwerk", "~> 2.6", ">= 2.6.0" - spec.add_runtime_dependency "uuidtools", "~> 2.1.5", ">= 2.1.5" - spec.add_development_dependency "rspec", "~> 3.6", ">= 3.6.0" spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|cassettes)/}) } diff --git a/lib/datadog_api_client/v2/model_base.rb b/lib/datadog_api_client/v2/model_base.rb index 7bdfde0c6bcd..cfc8c7051560 100644 --- a/lib/datadog_api_client/v2/model_base.rb +++ b/lib/datadog_api_client/v2/model_base.rb @@ -124,7 +124,7 @@ def _deserialize(type, value) # generic array, return directly value when :UUID - value.to_s + value when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } @@ -255,7 +255,9 @@ def find_and_cast_into_type(klass, data) when 'Object' # "type: object" return data if data.instance_of?(Hash) when 'UUID' - return UUIDTools::UUID.parse(data) + raise TypeError, "Expected String, got #{uuid_string.class.name} instead." unless uuid_string.kind_of?(String) + raise ArgumentError, "Invalid UUID format." unless /\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/.match?(data) + return data when /\AArray<(?.+)>\z/ # "type: array" if data.instance_of?(Array) sub_type = Regexp.last_match[:sub_type] From cd4d2ca5c8e3e48c1da0885ba213ad1ff6bbf9ab Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 17 Apr 2025 19:34:07 +0000 Subject: [PATCH 2/2] pre-commit fixes --- lib/datadog_api_client/v2/model_base.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/datadog_api_client/v2/model_base.rb b/lib/datadog_api_client/v2/model_base.rb index cfc8c7051560..7bdfde0c6bcd 100644 --- a/lib/datadog_api_client/v2/model_base.rb +++ b/lib/datadog_api_client/v2/model_base.rb @@ -124,7 +124,7 @@ def _deserialize(type, value) # generic array, return directly value when :UUID - value + value.to_s when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } @@ -255,9 +255,7 @@ def find_and_cast_into_type(klass, data) when 'Object' # "type: object" return data if data.instance_of?(Hash) when 'UUID' - raise TypeError, "Expected String, got #{uuid_string.class.name} instead." unless uuid_string.kind_of?(String) - raise ArgumentError, "Invalid UUID format." unless /\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/.match?(data) - return data + return UUIDTools::UUID.parse(data) when /\AArray<(?.+)>\z/ # "type: array" if data.instance_of?(Array) sub_type = Regexp.last_match[:sub_type]