Invalid UUID warning in UUIDFields cannot be escalated to exception

Bug #1746966 reported by Balazs Gibizer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.versionedobjects
Fix Released
Undecided
Balazs Gibizer

Bug Description

Adding warnings.filterwarnings('error', message=".*invalid UUID.*") to any of the lib's user code to force the warning to become an exception is not possible because the oslo implementation push a warning filter before emitting this warning [1]. As this extra filter becomes the fist filter in the filter list it overrides the filter [2] added by the user code.

[1] https://github.com/openstack/oslo.versionedobjects/blob/339b5f8e57009fd8abcc406d3597d84a2eb1e269/oslo_versionedobjects/fields.py#L350
[2] https://docs.python.org/2/library/warnings.html#warnings.filterwarnings

Changed in oslo.versionedobjects:
assignee: nobody → Balazs Gibizer (balazs-gibizer)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.versionedobjects (master)

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

Changed in oslo.versionedobjects:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.versionedobjects (master)

Reviewed: https://review.openstack.org/540344
Committed: https://git.openstack.org/cgit/openstack/oslo.versionedobjects/commit/?id=0e3526710f67b3b4ebab60864ea060fa9caf9537
Submitter: Zuul
Branch: master

commit 0e3526710f67b3b4ebab60864ea060fa9caf9537
Author: Balazs Gibizer <email address hidden>
Date: Fri Feb 2 12:16:30 2018 +0100

    Allow escalation of UUID validation warning to error

    Today UUIDField emits a warning if the provided value is not a valid
    UUID. However this warning cannot be escalated to an exception through
    the standard warnings module because the validation code also adds a
    warning filter to the warning filter list that overrides the existing
    filters.

    This patch ensures that the 'once' warning filter only added to the
    end of the filter list. This way if the client has already specified
    another filter for this warning (e.g. and error filter) then that
    filter will not be overriden.

    Change-Id: I17cb96d16fcd91195478b738fbdda01b47cfd69d
    Closes-Bug: #1746966

Changed in oslo.versionedobjects:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.versionedobjects 1.32.0

This issue was fixed in the openstack/oslo.versionedobjects 1.32.0 release.

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.