List with no resources raises IndexError: list index out of range

Bug #1547567 reported by Boden R
This bug report is a duplicate of:  Bug #1539770: Empty set causing out of range error. Edit Remove
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cliff
Fix Committed
Undecided
Unassigned

Bug Description

Using devstack all-in-one setup from master branch (neutron version 4.0.0).

Listing neutron resources that don't have any resources yet created causes an IndexError.

For example, I don't have any routers defined for my tenant:

ubuntu@l3-aa:~$ neutron router-list
list index out of range

If I run with debug to get the stack:

ubuntu@l3-aa:~$ neutron --debug router-list
...
DEBUG: keystoneauth.identity.v2 Making authentication request to http://10.34.232.114:5000/v2.0/tokens
DEBUG: keystoneauth.session REQ: curl -g -i -X GET http://10.34.232.114:9696/v2.0/routers.json -H "User-Agent: python-neutronclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}70a319daa6da4234b31561c5d33faa4b125cfdf3"
DEBUG: keystoneauth.session RESP: [200] Date: Fri, 19 Feb 2016 15:52:53 GMT Connection: keep-alive Content-Type: application/json; charset=UTF-8 Content-Length: 15 X-Openstack-Request-Id: req-34371266-83d1-4c83-ba18-186df09cbc99
RESP BODY: {"routers": []}

ERROR: neutronclient.shell list index out of range
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/neutronclient/shell.py", line 819, in run_subcommand
    return run_command(cmd, cmd_parser, sub_argv)
  File "/usr/local/lib/python2.7/dist-packages/neutronclient/shell.py", line 105, in run_command
    return cmd.run(known_args)
  File "/usr/local/lib/python2.7/dist-packages/neutronclient/common/command.py", line 29, in run
    return super(OpenStackCommand, self).run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/cliff/display.py", line 88, in run
    self.produce_output(parsed_args, column_names, data)
  File "/usr/local/lib/python2.7/dist-packages/cliff/lister.py", line 51, in produce_output
    parsed_args,
  File "/usr/local/lib/python2.7/dist-packages/cliff/formatters/table.py", line 64, in emit_list
    stdout, x, int(parsed_args.max_width), min_width)
  File "/usr/local/lib/python2.7/dist-packages/cliff/formatters/table.py", line 148, in _assign_max_widths
    first_line = x.get_string().splitlines()[0]
IndexError: list index out of range
list index out of range

Changed in python-neutronclient:
status: New → Confirmed
Revision history for this message
Hardik Italia (hardik-italia) wrote :

Seeing same behavior in my environment too without any neutron resource.

Changed in python-neutronclient:
status: Confirmed → In Progress
assignee: nobody → Ritesh Anand (ritesh-anand)
Revision history for this message
Ritesh Anand (ritesh-anand) wrote :

IMO Cliff commit 94cd83f9254db3cd9eb0d58e111a2c859f2fb2b8 is causing this behavior.

affects: python-neutronclient → python-cliff
Revision history for this message
Ritesh Anand (ritesh-anand) wrote :

Correction IMO Cliff commit 94cd83f9254db3cd9eb0d58e111a2c859f2fb2b8 fixes this behavior; we would get back to normal once we get the cliff later than that commit.
review link: https://review.openstack.org/#/c/279272/

affects: python-cliff → python-neutronclient
Changed in python-neutronclient:
status: In Progress → Opinion
assignee: Ritesh Anand (ritesh-anand) → nobody
Revision history for this message
Akihiro Motoki (amotoki) wrote :

This happens with cliff 1.16.0 and 1.17.0. cliff 1.15.0 works well.

Revision history for this message
Akihiro Motoki (amotoki) wrote :

It is a problem in cliff. A newer version of cliff needs to be released.
There is nothing to do in neutronclient.

affects: python-neutronclient → python-cliff
Revision history for this message
Akihiro Motoki (amotoki) wrote :
Changed in python-cliff:
status: Opinion → Fix Committed
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.