api_routes using update_by_uuid2 crash when passing existing values
Problem
Webapi routes using the update_by_uuid2 method crash if you try to update a record but pass the same value that is already in place in the database.
Datapaths is affected and filters will also be affected after https://github.com/axsh/openvnet/pull/513 is merged.
Reproduction
vnctl datapaths add --uuid dp-test2 --display-name test2 --dpid aa --node-id vna1
vnctl datapaths modify dp-test2 --display-name test2
---
:error: ArgumentError
:message: 'Expected: ''Vnet::ModelWrappers::Datapath''. Got: ''NilClass'''
:code: 500
Solution
The EventBase.internal_update method returns nil if there was no change and a model wrapper otherwise. The webapi expects to get a model wrapper at all times which causes a crash when it gets nil instead.
The webapi needs a model wrapper to formulate its response so that method should probably return one even if it's unchanged.
I have added a unit test that reproduces the problem in the fix-update-by-uuid2 branch. Please push your commits to that branch if you take up this issue.