Skip to content

Commit 9abd6fa

Browse files
committed
fix: pricing feature, ensure int type for tier_id_int
1 parent 6e27e1a commit 9abd6fa

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/aleph_client/commands/pricing.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,10 @@ def display_table_for(
229229
row.append(internet_cell)
230230
table.add_row(*row)
231231

232-
tier_data[tier_id] = SelectedTier(
233-
tier=tier_id,
232+
# Convert tier_id to int to ensure consistent typing
233+
tier_id_int = int(tier_id)
234+
tier_data[tier_id_int] = SelectedTier(
235+
tier=tier_id_int,
234236
compute_units=current_units,
235237
vcpus=unit_vcpus * current_units,
236238
memory=unit_memory * current_units,
@@ -302,9 +304,16 @@ def display_table_for(
302304
)
303305

304306
if selector and pricing_entity not in [PricingEntity.STORAGE, PricingEntity.WEB3_HOSTING]:
307+
# Make sure tier_data has at least one element before proceeding
308+
if not tier_data:
309+
typer.echo(f"No valid tiers found for {pricing_entity.value}")
310+
raise typer.Exit(1)
311+
305312
if not auto_selected:
306-
tier_id = validated_prompt("Select a tier by index", lambda tier_id: tier_id in tier_data)
307-
return next(iter(tier_data.values())) if auto_selected else tier_data[tier_id]
313+
tier_id = validated_prompt("Select a tier by index", lambda tier_id: int(tier_id) in tier_data)
314+
# Convert tier_id to integer since we store it as integer keys in tier_data
315+
return tier_data[int(tier_id)]
316+
return next(iter(tier_data.values()))
308317

309318
return None
310319

0 commit comments

Comments
 (0)