Skip to content

Brev 9311/fix invalid instance type error#386

Open
arush070 wants to merge 2 commits into
mainfrom
BREV-9311/fix-invalid-instance-type-error
Open

Brev 9311/fix invalid instance type error#386
arush070 wants to merge 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
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.

1 participant