From 773ffb65bf36b7ec07549be1e291189e1f71c91e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 25 May 2026 21:27:28 +0300 Subject: fix(client): use nil-safe fetch fallback in list_flavors/list_images Replace || fallback with Hash#fetch block in list_flavors and list_images. The old code incorrectly swapped falsy-but-present values (empty string, false, 0) via ||. fetch only falls through when the key is absent, preserving legitimate falsy values from the API. --- lib/hyperstack/client.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/hyperstack') diff --git a/lib/hyperstack/client.rb b/lib/hyperstack/client.rb index bb67318..7d81cd3 100644 --- a/lib/hyperstack/client.rb +++ b/lib/hyperstack/client.rb @@ -30,8 +30,8 @@ module HyperstackVM Array(response['data']).flat_map do |entry| Array(entry['flavors']).map do |flavor| flavor.merge( - 'region_name' => flavor['region_name'] || entry['region_name'], - 'gpu' => flavor['gpu'] || entry['gpu'] + 'region_name' => flavor.fetch('region_name') { entry['region_name'] }, + 'gpu' => flavor.fetch('gpu') { entry['gpu'] } ) end end @@ -42,8 +42,8 @@ module HyperstackVM Array(response['images']).flat_map do |entry| Array(entry['images']).map do |image| image.merge( - 'region_name' => image['region_name'] || entry['region_name'], - 'type' => image['type'] || entry['type'] + 'region_name' => image.fetch('region_name') { entry['region_name'] }, + 'type' => image.fetch('type') { entry['type'] } ) end end -- cgit v1.2.3