nsot
nsot copied to clipboard
Using browseable API to update Interface object with empty attributes raises 400
The attributes field should default to an empty object ({}) but it's blank. So if the attributes for an Interface object are unset, upon clicking "PUT" to update the instance, a 400 is raised from the browseable API:
PUT /api/sites/1/interfaces/foo14-ab01:s45/
HTTP 400 Bad Request
Allow: GET, PUT, PATCH, DELETE, OPTIONS
Content-Type: application/json
Vary: Accept
{
"error": {
"message": {
"attributes": "Expected dictionary but received <type 'NoneType'>"
},
"code": 400
}
}
Strangely despite the error, any update still succeeds (such as if you're updating the description field). Also, if one puts {} into the attributes field and submits with the "PUT" button, the operation succeeds without any error.
There's something fishy going on here and appears to be two issues:
- The default value for the
attributesfield should be{}if the field is empty. - The validation of the attributes field appears to block only update to that field and not update to the entire object.