equinix / metal-cli

Official Equinix Metal CLI
https://deploy.equinix.com/labs/metal-cli
MIT License
59 stars 46 forks source link

[Bug]: ASN number validation #453

Closed triqster closed 2 months ago

triqster commented 7 months ago

What happened?

When trying to perform a metal vrf get on an project with a VRF that has a 4-byte ASN above between 2147483647 - 4294967295 it will trow the following error: Error: error when callingVRFsApi.FindVrfs`: json: cannot unmarshal number 4219099099 into Go struct field _VrfList.vrfs of type int32

Validation using int32 is a bug i think and should be uint32:

A 4-byte ASN is a 32-bit number. This format provides for 232 or 4,294,967,296 ASNs (0 to 4294967295) ref: https://www.arin.net/resources/guide/asn/#:~:text=A%204%2Dbyte%20ASN%20is,to

int32 range: -2147483648 to 2147483647 uint32 range: 0 to 4294967295

How can we reproduce it?

Create a VRF using the Portal or API with a ASN somewhere between 2147483647 - 4294967295. Then try to fetch the VRF using the Metal CLI with metal vrf get.

CLI version (metal --version):

triqster commented 7 months ago

The recent terraform provider has the same validation issues: https://github.com/equinix/terraform-provider-equinix/issues/613

displague commented 7 months ago

Depends on https://github.com/equinix/equinix-sdk-go/issues/41

dlotterman commented 5 months ago

I think it's generally captured here already but just wanted to add for clarity, it also looks like this hits metal project bgp-* functionllity, for example the act of enabling BGP via the CLI fallsback to 6500 regardless of user specification:

metal project bgp-enable -p $METAL_PROJECT_ID --deployment-type local --md5 STRING --asn 65111
+--------------------------------------+---------+-------+----------------+
|                  ID                  | USECASE |  ASN  | DEPLOYMENTTYPE |
+--------------------------------------+---------+-------+----------------+
| 051e2100-7488-49a7-ac65-b2d120a7dff2 |         | 65111 | local          |
+--------------------------------------+---------+-------+----------------+
 metal project bgp-config -p 051e2100-7488-49a7-ac65-b2d120a7dff2
+--------------------------------------+---------+-------+----------------+-----------+
|                  ID                  | STATUS  |  ASN  | DEPLOYMENTTYPE | MAXPREFIX |
+--------------------------------------+---------+-------+----------------+-----------+
| 051e2100-7488-49a7-ac65-b2d120a7dff2 | enabled | 65000 | local          | 10        |
+--------------------------------------+---------+-------+----------------+-----------+
ctreatma commented 2 months ago

Fixed in v0.23.0