Something wrong in validator when get invalid property

Bug #1531841 reported by ting.wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Barbican
Fix Released
Undecided
ting.wang

Bug Description

cannot retrieve correct error message when schema.ValidationError throw.

I find it when i look through the code, and there's a TODO in source code ( barbican/tests/common/test_validators.py: 638 ) because that test case cannot be passed.
I find out the reason.

Problem happens here.
In barbican/common/validators.py: 160, when request cannot pass the JSONschema check, an exception called schema.ValidationError will be thrown. And then procedure catches it and raises a object called exception.InvalidObject(). The object contains the information about invalid_property which we want to compare with "type" in the test case. But unfortunately, it cannot retrieve invalid property as expect.
In normal, validation_error.schema_path like ['','name',''] and we get validation_error.schema_path[1] which we need. But validation_error.schema_path likes ['required'] when no type in container request. So we cannot get validation_error.schema_path[1] and return none.

ting.wang (bx-wang)
Changed in barbican:
assignee: nobody → tingwang (bx-wang)
description: updated
description: updated
ting.wang (bx-wang)
description: updated
ting.wang (bx-wang)
description: updated
Revision history for this message
ting.wang (bx-wang) wrote :

But I'm a little confused about how to fix it.
I come up with 2 solutions.
1. add ELSE expression in barbican/common/validators.py: get_invalid_property() to handle the case that no type in create container request.
2. close the bug and maintain the que because it effect only in test case.

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

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

Changed in barbican:
status: New → In Progress
Revision history for this message
ting.wang (bx-wang) wrote :

we can use assertIn instead.

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

Reviewed: https://review.openstack.org/276987
Committed: https://git.openstack.org/cgit/openstack/barbican/commit/?id=a33fcd78efc6ae16492f3202ae7b6f536dc4b7a7
Submitter: Jenkins
Branch: master

commit a33fcd78efc6ae16492f3202ae7b6f536dc4b7a7
Author: ting.wang <email address hidden>
Date: Sat Feb 6 10:51:10 2016 +0800

    Active a unit test in comon/test_validators

    In a word, the reason why type is None is that JSONSchema
    checker doesn't return the unified form when the outmost layer
    of JSONSchema doesn't pass the examination.

    So, we can use assertIn instead.

    Change-Id: I49a2879ce249d83ee7ab36f1e0a67fe887aa4738
    Closes-bug: #1531841

Changed in barbican:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/barbican 4.0.0.0b2

This issue was fixed in the openstack/barbican 4.0.0.0b2 development milestone.

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.