Skip to content

Conversation

@canyugs
Copy link

@canyugs canyugs commented Jan 17, 2026

Before:
截圖 2026-01-20 下午4 20 39

After:
截圖 2026-01-20 下午4 19 32

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.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed region selection during project creation to ensure only available regions are properly considered, preventing errors from selecting unavailable options.

✏️ Tip: You can customize this high-level summary in your review settings.

… 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.
Copilot AI review requested due to automatic review settings January 17, 2026 03:14
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Walkthrough

Modifies region selection logic in the selector package to filter regions by availability before using them for project creation, ensuring the selected region index corresponds to an available region.

Changes

Cohort / File(s) Summary
Region Availability Filtering
pkg/selector/selector.go
Introduces availableRegions slice filtered by IsAvailable status; changes project region lookup to use filtered list instead of full regions list to ensure selected index aligns with available regions only

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • pan93412
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a region index mapping bug when unavailable regions are filtered in template deploy.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/fix-free-tier-deployment-vGHH5

Comment @coderabbitai help to get the list of available commands and usage tips.

@canyugs
Copy link
Author

canyugs commented Jan 17, 2026

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug where free tier users selecting a region during CLI template deployment would encounter "REQUIRE_PAID_PLAN" errors even when choosing available regions. The issue was caused by an index mismatch between filtered and unfiltered region arrays.

Changes:

  • Added availableRegions slice to track only available regions alongside the existing regionOptions string array
  • Updated region selection logic to use availableRegions array instead of the original unfiltered regions array when mapping user's selected index

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/selector/selector.go (1)

105-119: Guard against zero available regions before prompting/indexing.

If all regions are unavailable, availableRegions is empty and the subsequent indexing can panic. Handle the empty case explicitly and return a user-facing error.

🐛 Proposed fix
  availableRegions := make([]model.GenericRegion, 0, len(regions))
  regionOptions := make([]string, 0, len(regions))
  for _, region := range regions {
    if region.IsAvailable() {
      availableRegions = append(availableRegions, region)
      regionOptions = append(regionOptions, region.String())
    }
  }
+ if len(availableRegions) == 0 {
+   return nil, nil, errors.New("no available regions for your plan")
+ }

  projectRegionIndex, err := s.prompter.Select("Select project region", "", regionOptions)
  if err != nil {
    return nil, nil, fmt.Errorf("select project region failed: %w", err)
  }

  projectRegion := availableRegions[projectRegionIndex].GetID()

@canyugs canyugs self-assigned this Jan 19, 2026
@canyugs canyugs merged commit 5c2f6ee into main Jan 20, 2026
11 checks passed
@canyugs canyugs deleted the claude/fix-free-tier-deployment-vGHH5 branch January 20, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants