Non-JSON policy file causing failure to load policy

Bug #1177365 reported by git-harry on 2013-05-07
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

If the file /etc/glance/policy.json is not valid JSON data an unhandled exception is raised by the JSON decoder.

$ glance image-list
Request returned failure status.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/", line 383, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/", line 367, in __call__
    response = req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/webob/", line 1296, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/", line 1260, in call_application
    app_iter = application(self.environ, start_response)
  File "/opt/stack/python-keystoneclient/keystoneclient/middleware/", line 451, in __call__
    return, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/", line 364, in __call__
    response = self.process_request(req)
  File "/opt/stack/glance/glance/api/middleware/", line 79, in process_request
    req.context = self._get_authenticated_context(req)
  File "/opt/stack/glance/glance/api/middleware/", line 125, in _get_authenticated_context
    return glance.context.RequestContext(**kwargs)
  File "/opt/stack/glance/glance/", line 46, in __init__
  File "/opt/stack/glance/glance/api/", line 155, in check_is_admin
    return self.check(context, 'context_is_admin', target)
  File "/opt/stack/glance/glance/api/", line 145, in check
    return self._check(context, action, target)
  File "/opt/stack/glance/glance/api/", line 115, in _check
  File "/opt/stack/glance/glance/api/", line 67, in load_rules
    rules = self._read_policy_file()
  File "/opt/stack/glance/glance/api/", line 99, in _read_policy_file
    rules_dict = json.loads(raw_contents)
  File "/usr/lib/python2.7/json/", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
 (HTTP 500)

git-harry (git-harry) on 2013-05-07
Changed in glance:
assignee: nobody → git-harry (git-harry)

Fix proposed to branch: master

Changed in glance:
status: New → In Progress
Changed in glance:
importance: Undecided → Low
Erno Kuvaja (jokke) on 2014-09-12
Changed in glance:
status: In Progress → New
assignee: git-harry (git-harry) → nobody
Changed in glance:
assignee: nobody → agileclipse (agileclipse)
Louis Taylor (kragniz) on 2014-11-17
Changed in glance:
importance: Low → Wishlist
status: New → Confirmed
Kamil Rykowski (kamil-rykowski) wrote :

I guess that the issue has been solved by moving to the oslo_policy. Right now if there is an error inside policy file, oslo will raise an exception with information about what happened and what is wrong with the policy.json eg:

ValueError: Expecting ',' delimiter: line 5 column 5 (char 64)

Ian Cordasco (icordasc) on 2015-05-23
Changed in glance:
assignee: agileclipse (agileclipse) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers