NoSuchOptError thrown for bad choice value in StrOpt

Bug #1499074 reported by Davanum Srinivas (DIMS)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.config
Fix Released
Undecided
Davanum Srinivas (DIMS)

Bug Description

Reported by Anton Arefiev. If we have a StrOpt with a choices parameter and a config file with a wrong value, we end up throwing a NoSuchOptError.

2015-09-23 17:31:41.832 TRACE ironic Traceback (most recent call last):
2015-09-23 17:31:41.832 TRACE ironic File "/usr/local/bin/ironic-api", line 10, in <module>
2015-09-23 17:31:41.832 TRACE ironic sys.exit(main())
2015-09-23 17:31:41.832 TRACE ironic File "/opt/stack/ironic/ironic/cmd/api.py", line 50, in main
2015-09-23 17:31:41.832 TRACE ironic app.VersionSelectorApplication(),
2015-09-23 17:31:41.832 TRACE ironic File "/opt/stack/ironic/ironic/api/app.py", line 98, in __init__
2015-09-23 17:31:41.832 TRACE ironic pc.app.enable_acl = (CONF.auth_strategy == 'keystone')
2015-09-23 17:31:41.832 TRACE ironic File "/usr/local/lib/python2.7/dist-packages/oslo_config/cfg.py", line 1902, in __getattr__
2015-09-23 17:31:41.832 TRACE ironic raise NoSuchOptError(name)
2015-09-23 17:31:41.832 TRACE ironic NoSuchOptError: no such option: auth_strategy

We should expose the original message which is thrown here, as it shows correctly that the option is defined correctly and it's just the value is wrong.
https://github.com/openstack/oslo.config/blob/master/oslo_config/types.py#L79

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

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

Changed in oslo.config:
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.config (master)

Reviewed: https://review.openstack.org/226993
Committed: https://git.openstack.org/cgit/openstack/oslo.config/commit/?id=934ae9b34f7ab4bba5b1a4573a714d803a4c1707
Submitter: Jenkins
Branch: master

commit 934ae9b34f7ab4bba5b1a4573a714d803a4c1707
Author: Davanum Srinivas <email address hidden>
Date: Wed Sep 23 16:55:10 2015 -0400

    Fix bad exception for StrOpt with invalid choice value

    If there's a StrOpt with name foo and say choices ['bar', 'baz'] and the
    config file has a bad value for foo (say 'boo'), then the end user
    will see:
    NoSuchOptError: no such option: foo

    Which gives the wrong impression that somehow the foo was never registered
    which is wrong!

    They should see this instead:
    oslo_config.cfg.ConfigFileValueError: Value for option foo is not
    valid: Valid values are [bar, baz], but found 'boo'

    Closes-Bug: #1499074
    Change-Id: I694d8aa99c861c7b47bae77ef12f435b7c3712ab

Changed in oslo.config:
status: In Progress → Fix Committed
Changed in oslo.config:
milestone: none → 2.5.0
status: Fix Committed → Fix Released
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.