dropbox / nsot

Network Source of Truth is an open source IPAM and network inventory database
https://nsot.readthedocs.io
Other
399 stars 66 forks source link

Using browseable API to update Interface object with empty attributes raises 400 #313

Open jathanism opened 6 years ago

jathanism commented 6 years ago

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: