Skip to content

Brev 9311/fix invalid instance type error#386

Merged
patelspratik merged 2 commits into
mainfrom
BREV-9311/fix-invalid-instance-type-error
Jun 8, 2026
Merged

Brev 9311/fix invalid instance type error#386
patelspratik merged 2 commits into
mainfrom
BREV-9311/fix-invalid-instance-type-error

Conversation

@arush070
Copy link
Copy Markdown
Contributor

Problem

brev create --type <x> printed the backend's internal message
cloudCredId or workspaceGroupId must be specified whenever:

  • the instance type was unrecognized (typo), or
  • the type was valid but had no capacity for the caller's org.

Change

Two-layer validation, both in CLI code (no parsing of backend strings):

  1. Pre-flight skip in createInstancesWithType
    • New validateInstanceTypeAvailability(spec.Type) returns breverrors.ValidationError with one of:
      • instance type "<x>" is not a recognized type; run 'brev search' to see available types
      • instance type "<x>" is currently unavailable (no capacity); try again later or run 'brev search' to find another type
    • Logged as Skipping: <message> so the user sees the type once.
    • Bypassed for --launchable (launchables supply their own workspace group and may reference types outside the org listing).
  2. Structural pre-condition in createWorkspace
    • If cwOptions.WorkspaceGroupID == "" after all resolution paths (instance-type lookup, launchable config), return a ValidationError before the API call. Separate message when the listing API itself was unavailable, so the user can retry vs. fix
      the type.
  3. Supporting helper AllInstanceTypesResponse.HasInstanceType in pkg/cmd/gpusearch/gpusearch.go so the validation can tell "unknown" from "known but no groups".

Tests

New cases:

  • TestValidateInstanceTypeAvailability (5 subtests: nil listing, valid group, unknown type, known-but-no-groups, error is ValidationError)
  • TestCreateInstancesWithTypeSkipsInvalidType
  • TestCreateInstancesWithTypeSkipsUnavailableType
  • TestCreateInstancesWithTypeBypassesValidationForLaunchable
  • TestAllInstanceTypesResponseLookup (5 subtests forGetWorkspaceGroupID + HasInstanceType)

@arush070 arush070 requested a review from a team as a code owner May 11, 2026 01:58
@arush070 arush070 self-assigned this May 11, 2026
patelspratik
patelspratik previously approved these changes Jun 1, 2026
@arush070 arush070 force-pushed the BREV-9311/fix-invalid-instance-type-error branch from efe1c6d to d01746f Compare June 8, 2026 05:33
@arush070
Copy link
Copy Markdown
Contributor Author

arush070 commented Jun 8, 2026

Hi @patelspratik ,

Thanks for your previous approval on this PR.
As this PR remained open while main continued to move ahead, some merge conflicts came up. We have now resolved those conflicts and rebased the PR onto the latest main, while keeping the same changes that were previously approved.
Could you please review it once more? Once approved, please let us know if we are good to merge.

Thanks in advance.

@patelspratik patelspratik merged commit 1fc7a42 into main Jun 8, 2026
9 checks passed
@patelspratik patelspratik deleted the BREV-9311/fix-invalid-instance-type-error branch June 8, 2026 18:16
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.

2 participants