Search fails if response from API service contains additional keys

Bug #1621061 reported by Yuriy Zveryanskyy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-searchlightclient
Confirmed
Medium
Yuriy Zveryanskyy

Bug Description

Response from API search entry point can contains additional keys in data list elements (which are not hardcoded in the client).
Search fails with exeption from the client for this case.
Example for ironic plugin (under development):

run(Namespace(all_projects=False, columns=[], formatter='table', json=True, max_width=0, noindent=False, query=u'{"term": {"uuid": "145eab3b-9296-4b31-939f-01e44feb39a5"}}', quote_mode='nonnumeric', source='all_sources', type=None))
take_action(Namespace(all_projects=False, columns=[], formatter='table', json=True, max_width=0, noindent=False, query=u'{"term": {"uuid": "145eab3b-9296-4b31-939f-01e44feb39a5"}}', quote_mode='nonnumeric', source='all_sources', type=None))
Making authentication request to http://192.168.122.156/identity/v2.0/tokens
"POST /identity/v2.0/tokens HTTP/1.1" 200 3042
REQ: curl -g -i -X POST http://192.168.122.156:9393/v1/search -H "User-Agent: python-searchlightclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}a885d2679d8e2e5945b939bb2efda7fa016f0fcf" -d '{"query": {"term": {"uuid": "145eab3b-9296-4b31-939f-01e44feb39a5"}}, "type": null, "all_projects": false}'
Starting new HTTP connection (1): 192.168.122.156
"POST /v1/search HTTP/1.1" 200 694
RESP: [200] Content-Length: 694 Content-Type: application/json; charset=UTF-8 X-Openstack-Request-Id: req-f96e5cb9-1161-43a8-a927-64c14f5c1461 Date: Wed, 07 Sep 2016 11:51:11 GMT Connection: keep-alive
RESP BODY: {"hits": {"hits": [{"_type": "OS::Ironic::Port", "_routing": "6e175dbf-bcc6-43a7-a42f-d82c1ef5f4e0", "_index": "searchlight-2016_09_01_14_56_14", "_score": 5.069027, "_source": {"local_link_connection": {}, "node_uuid": "6e175dbf-bcc6-43a7-a42f-d82c1ef5f4e0", "uuid": "145eab3b-9296-4b31-939f-01e44feb39a5", "extra": {}, "pxe_enabled": true, "created_at": "2016-09-05T11:47:32Z", "updated_at": "2016-09-05T11:50:14Z", "address": "22:55:66:77:88:aa", "internal_info": {}}, "_parent": "6e175dbf-bcc6-43a7-a42f-d82c1ef5f4e0", "_id": "145eab3b-9296-4b31-939f-01e44feb39a5"}], "total": 1, "max_score": 5.069027}, "_shards": {"successful": 5, "failed": 0, "total": 5}, "took": 24, "timed_out": false}

u'_routing'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 387, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/cliff/display.py", line 100, in run
    column_names, data = self.take_action(parsed_args)
  File "/opt/stack/python-searchlightclient/searchlightclient/osc/v1/search.py", line 121, in take_action
    converted[mapping[k]] = v
KeyError: u'_routing'
clean_up SearchResource: u'_routing'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/shell.py", line 135, in run
    ret_val = super(OpenStackShell, self).run(argv)
  File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 267, in run
    result = self.run_subcommand(remainder)
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/shell.py", line 180, in run_subcommand
    ret_value = super(OpenStackShell, self).run_subcommand(argv)
  File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 387, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/cliff/display.py", line 100, in run
    column_names, data = self.take_action(parsed_args)
  File "/opt/stack/python-searchlightclient/searchlightclient/osc/v1/search.py", line 121, in take_action
    converted[mapping[k]] = v
KeyError: u'_routing'

Changed in python-searchlightclient:
assignee: nobody → Yuriy Zveryanskyy (yzveryanskyy)
description: updated
Liyingjun (liyingjun)
Changed in python-searchlightclient:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-searchlightclient 1.1.0

This issue was fixed in the openstack/python-searchlightclient 1.1.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.