metadata type guessing code not robust

Bug #1221736 reported by Doug Hellmann
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Medium
Doug Hellmann

Bug Description

Heat is passing values to the query engine that look like expressions, but aren't. The code in the API that tries to convert the incoming value to the right type using ast is getting an unhandled SyntaxError for that case.

>>> ast.literal_eval('WWW-Layer-4a80714f-0232-4580-aa5e-81494d1a4147-uolhh25p5xxm')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 49, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
    WWW-Layer-4a80714f-0232-4580-aa5e-81494d1a4147-uolhh25p5xxm

We should:

1. Catch SyntaxError.
2. Not try to do type guessing if the incoming value contains punctuation characters (especially - and + since those will result in expressions, so a value like 10-1 will come out 9 and be completely wrong in all senses).

Changed in ceilometer:
assignee: nobody → Doug Hellmann (doug-hellmann)
status: New → In Progress
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

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

Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

See also bug #1215840

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

Reviewed: https://review.openstack.org/45438
Committed: http://github.com/openstack/ceilometer/commit/37a779065f73c47ccdd87b09b59030c01ff190ba
Submitter: Jenkins
Branch: master

commit 37a779065f73c47ccdd87b09b59030c01ff190ba
Author: Doug Hellmann <email address hidden>
Date: Fri Sep 6 10:33:41 2013 -0400

    Make type guessing for query args more robust

    Improve the error handling of the type-guesser for queries
    against metadata fields, and add some test coverage for
    specific cases that came out of the discussion of the
    source of the bug.

    Fixes bug #1221736

    Change-Id: I27f84aa2538d2a69a3d7b7e93c36813df8d35204

Changed in ceilometer:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: none → havana-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: havana-rc1 → 2013.2
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.