Leading spaces to a configuration key causes and exception

Bug #1088814 reported by Gary Kotton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Invalid
Undecided
Gary Kotton

Bug Description

openstack@ubuntu-devstack:/opt/stack/quantum$ cd /opt/stack/quantum && python /opt/stack/quantum/bin/quantum-server --config-file /etc/quantum/quantum.conf --config-file /etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini
Traceback (most recent call last):
  File "/opt/stack/quantum/bin/quantum-server", line 27, in <module>
    server()
  File "/opt/stack/quantum/quantum/server/__init__.py", line 33, in main
    config.parse(sys.argv)
  File "/opt/stack/quantum/quantum/common/config.py", line 68, in parse
    version='%%prog %s' % quantum_version.version_string_with_vcs())
  File "/opt/stack/quantum/quantum/openstack/common/cfg.py", line 1026, in __call__
    self._parse_config_files()
  File "/opt/stack/quantum/quantum/openstack/common/cfg.py", line 1492, in _parse_config_files
    raise ConfigFileParseError(pe.filename, str(pe))
quantum.openstack.common.cfg.ConfigFileParseError: Failed to parse /etc/quantum/quantum.conf: at /etc/quantum/quantum.conf:2, Unexpected continuation line: ' rabbit_password = openstack'

Gary Kotton (garyk)
Changed in oslo:
assignee: nobody → Gary Kotton (garyk)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

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

Changed in oslo:
status: New → In Progress
Revision history for this message
Mark McLoughlin (markmc) wrote :

You don't give any context of why you think this is more than just a user error, but I see a leading space there as simply not allowed by standard .ini file syntax

See this experiment with 3 other APIs:

  https://gist.github.com/4257865

The only one which allows it is configobj which does so specifically for subsection indentation e.g.

  [foo]
  blaa = 1

      [[bar]]
      foobar = 2

Extending the syntax to be non-standard would limit our implementation choices in the future and might also make things difficult for tools which read and modify these files - e.g. a leading space would cause the openstack-config[1] utility to fail

[1] - https://github.com/fedora-openstack/openstack-utils/blob/master/utils/openstack-config

Changed in oslo:
status: In Progress → Invalid
Revision history for this message
Gary Kotton (garyk) wrote :

Hi,
I do not agree with you:
1. Why does the application need to terminate if the user makes a trivial mistake. A simple use case is the user copy pasting a configuration file from one device to another. She/he may add in a space by mistake and hence have to dig into reasons why the application no longer starts.
2. I did not find anywhere where it indicates that spaces are forbidden to trail a key in ini files. Please look at:
https://github.com/editorconfig/editorconfig/issues/37
http://code.google.com/p/minini/wiki/INI_File_Syntax (there is a typo in the relevant text but I'll not hold them to it).
In the example above the leading whitespaces will only be removed for the key and not the section.
I would hope that you would reconsider moving this from invalid as it may just enhance the user experience.
Thanks
Gary

Revision history for this message
Mark McLoughlin (markmc) wrote :

1. Better that a user gets an error immediately when they mistake rather than things breaking later - I think the fact that this breaks openstack-config and, likely, tools like puppet and chef is worse for "user experience"

2. The ".ini style" syntax is not really specified very well anywhere, but I've shown examples of the most common Python .ini file parsers not supporting it and my experience of other parsers in C, Ruby, etc. all suggest that this isn't commonly accepted syntax. Your editorconfig example is of a config file syntax that has varied significantly from the basic .ini syle and minini looks like a fairly obscure implementation.

Revision history for this message
Gary Kotton (garyk) wrote :

Hi,
This could be considered a bug with openstack-config. I am not familiar with chef and/or puppet implementations regarding the matter. FYI - http://bugs.python.org/issue1524825. So when openstack upgrades to python 3.2 we can readdress the matter (or get it resolved).
Thanks
Gary

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.