improvements to API validation logic

Bug #1076813 reported by dan wendlandt
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Henry Gessau

Bug Description

The last round of reviews for https://review.openstack.org/#/c/14219/ specified a few more areas for improvement in validation code that we could do.

One is to no longer catch generic Exceptions like AttributeError, etc. and convert them into HTTP 400s, as it is possible that those errors are actually the result of internal server errors (i.e., should be HTTP 500s). Ideally, we could catch these closer to the source where it was possible to tell if they happened during input validation (i.e.., are a 400) or later in server processing (i.e., are a 500).

Also, there are a couple cases where the validation messages could be improved, in particular, places where we say something like "invalid fixes ip", but then print the entire list of fixed IPs. Ideally we would either report that the item is not a list, or indicate that a particular list member was detected as invalid.

dan wendlandt (danwent)
Changed in quantum:
status: New → Confirmed
importance: Undecided → Low
tags: added: low-hanging-fruit
Henry Gessau (gessau)
Changed in quantum:
assignee: nobody → Henry Gessau (gessau)
Henry Gessau (gessau)
Changed in quantum:
status: Confirmed → In Progress
Revision history for this message
Henry Gessau (gessau) wrote :

Does HTTP 400 make sense for this test?

quantum/quantum/tests/unit/test_db_plugin.py, line 602:
    def test_update_invalid_json_400(self):
        with self.network() as net:
            req = self.new_update_request('networks',
                                          '{{"name": "aaa"}}',
                                          net['network']['id'])
            res = req.get_response(self.api)
            self.assertEqual(res.status_int, 400)

Revision history for this message
Henry Gessau (gessau) wrote :

Answering my own question:
Yes BadRequest does make sense because the data '{{"name": "aaa"}}' is the wrong type/format for the 'networks' resource.

Gary Kotton (garyk)
tags: added: api
Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

This bug is marked in progress, but we're lacking a link to a gerrit patchset; I did a little search on gerrit but could not find any.

Henry, can you point me to the correct review? (or fix the commit message there so launchpad is automatically updated)

Revision history for this message
Henry Gessau (gessau) wrote :

Sorry, being new to this process I mis-interpreted the meaning of "in progress".
I am working on it but not yet ready to send out changes for review.
What should the status be set to?

Revision history for this message
Akihiro Motoki (amotoki) wrote :

Hi Henry,

"In Progress" without a patch on gerrit is a valid status.
On the other hand, OpenStack gerrit automatically updates the status of Launchpad bug when the patch is uploaded for revierw. Thus a patch is available on gerrit in most cases. This is what Salvatore says.
If you set the status to "In Progress", please keep your status up-to-date. It is helpful.

Now the limit of G-3 development milestone is coming and we quantum-core needs to trace the status of each bug.

Thanks,

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

No worries. I'll keep it target for G-3 (but being a low priority bug it might be untargeted again - especially if the code is pushed close to the deadline)

Changed in quantum:
milestone: none → grizzly-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to quantum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/21460

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to quantum (master)

Reviewed: https://review.openstack.org/21460
Committed: http://github.com/openstack/quantum/commit/be77455856fcc88300b0ad5a36211ebd37f0e453
Submitter: Jenkins
Branch: master

commit be77455856fcc88300b0ad5a36211ebd37f0e453
Author: Henry Gessau <email address hidden>
Date: Thu Feb 7 16:01:28 2013 -0500

    Improvements to API validation logic.

    Do not automatically map generic exceptions like AttributeError to
    http errors (instead they should be handled closer to where they occur
    so that they can be "intelligently" converted to the appropriate
    error).

    Fix up some expected error codes in the unit tests.
    Improve some of the validation messages.
    Remove all use of locals() in attributes.py

    Fixes: bug #1076813
    Change-Id: Iabf8808a840e927307bbcae4cd41790af3d79a9e

Changed in quantum:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in quantum:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in quantum:
milestone: grizzly-3 → 2013.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.