diff --git a/README.md b/README.md index b82742238f..7d7f5337ae 100644 --- a/README.md +++ b/README.md @@ -1184,6 +1184,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address' ### master (unreleased) +* Fix panic when the commercial-type is lower than 2 characters ([#365](https://github.com/scaleway/scaleway-cli/issues/365)) * gotty-client enable ProxyFromEnviromnent ([#363](https://github.com/scaleway/scaleway-cli/pull/363)) ([@debovema](https://github.com/debovema)) * `scw inspect` fix panic ([#353](https://github.com/scaleway/scaleway-cli/issues/353)) * Clear cache between the releases ([#329](https://github.com/scaleway/scaleway-cli/issues/329)) diff --git a/pkg/api/helpers.go b/pkg/api/helpers.go index 581a581bb3..8421b7aa6a 100644 --- a/pkg/api/helpers.go +++ b/pkg/api/helpers.go @@ -283,6 +283,9 @@ func CreateServer(api *ScalewayAPI, c *ConfigCreateServer) (string, error) { if commercialType == "" { commercialType = c.CommercialType } + if len(commercialType) < 2 { + return "", errors.New("Invalid commercial type") + } if c.Name == "" { c.Name = strings.Replace(namesgenerator.GetRandomName(0), "_", "-", -1)