UniFi - Troubleshooting - Failed to save network
Problem#
I was trying to make a change to one of the Networks from the UniFi Controller, and I was unable to save the settings due to the following error:

I managed to grabbed the response from the Developer Tools, Network tab:
{
"meta": {
"rc": "error",
"msg": "api.err.InvalidPayload"
},
"data": [
{
"validationError": {
"field": "wan_gateway",
"pattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
},
"rc": "error",
"msg": "api.err.InvalidValue"
}
]
}It seems the issue is in the wan_gateway is not valid, and sure enough looking at the payload request (trimmed to relevant part), it's empty:
{
"wan_type": "dhcp",
"wan_gateway": "",
}I believe that this has happened due to a bug in a Terraform that might have put the controller in a bad state, or an update gone wrong; I can't be sure.
Solution#
To fix the issue, copy the request as cURL and set wan_gateway to 0.0.0.0 and make the call. The modified payload should look like this:
{
"wan_type": "dhcp",
"wan_gateway": "0.0.0.0",
}