Skip to content

Commit 0137a55

Browse files
committed
fix: correct region index mapping in template deploy when unavailable regions are filtered
When free tier users deploy using CLI template deploy command and select a region, they were encountering "REQUIRE_PAID_PLAN" errors even when selecting available regions. This was caused by an index mismatch bug in pkg/selector/selector.go where: - regionOptions array contained only available regions (filtered) - User selected an index from this filtered list - Code used that index on the original unfiltered regions array This resulted in selecting the wrong region (potentially an unavailable one). The fix creates a separate availableRegions array and uses it for indexing, matching the pattern already applied to internal/cmd/project/create/create.go in commit 8e5d1ab.
1 parent 89892da commit 0137a55

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/selector/selector.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ func (s *selector) SelectProject(opts ...SelectProjectOptionsApplyer) (zcontext.
102102
return nil, nil, fmt.Errorf("get regions failed: %w", err)
103103
}
104104

105+
availableRegions := make([]model.GenericRegion, 0, len(regions))
105106
regionOptions := make([]string, 0, len(regions))
106107
for _, region := range regions {
107108
if region.IsAvailable() {
109+
availableRegions = append(availableRegions, region)
108110
regionOptions = append(regionOptions, region.String())
109111
}
110112
}
@@ -114,7 +116,7 @@ func (s *selector) SelectProject(opts ...SelectProjectOptionsApplyer) (zcontext.
114116
return nil, nil, fmt.Errorf("select project region failed: %w", err)
115117
}
116118

117-
projectRegion := regions[projectRegionIndex].GetID()
119+
projectRegion := availableRegions[projectRegionIndex].GetID()
118120

119121
project, err := s.client.CreateProject(context.Background(), projectRegion, nil)
120122
if err != nil {

0 commit comments

Comments
 (0)