Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api_routes using update_by_uuid2 crash when passing existing values #515

Open
Metallion opened this issue Dec 16, 2016 · 0 comments
Open

Comments

@Metallion
Copy link
Contributor

Metallion commented Dec 16, 2016

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 #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant