Empty set causing out of range error

Bug #1539770 reported by Adam Young
66
This bug affects 9 people
Affects Status Importance Assigned to Milestone
cliff
Fix Released
Undecided
Doug Hellmann

Bug Description

Using cliff with openstack client when querying against an empty collection reports an error:

 openstack --debug server list #no servers defined

list index out of range
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 379, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/site-packages/cliff/display.py", line 93, in run
    self.produce_output(parsed_args, column_names, data)
  File "/usr/lib/python2.7/site-packages/cliff/lister.py", line 56, in produce_output
    parsed_args,
  File "/usr/lib/python2.7/site-packages/cliff/formatters/table.py", line 64, in emit_list
    stdout, x, int(parsed_args.max_width), min_width)
  File "/usr/lib/python2.7/site-packages/cliff/formatters/table.py", line 148, in _assign_max_widths
    first_line = x.get_string().splitlines()[0]
IndexError: list index out of range
clean_up ListServer: list index out of range
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/openstackclient/shell.py", line 113, in run
    ret_val = super(OpenStackShell, self).run(argv)
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 259, in run
    result = self.run_subcommand(remainder)
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 379, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/site-packages/cliff/display.py", line 93, in run
    self.produce_output(parsed_args, column_names, data)
  File "/usr/lib/python2.7/site-packages/cliff/lister.py", line 56, in produce_output
    parsed_args,
  File "/usr/lib/python2.7/site-packages/cliff/formatters/table.py", line 64, in emit_list
    stdout, x, int(parsed_args.max_width), min_width)
  File "/usr/lib/python2.7/site-packages/cliff/formatters/table.py", line 148, in _assign_max_widths
    first_line = x.get_string().splitlines()[0]
IndexError: list index out of range

Revision history for this message
Adam Young (ayoung) wrote :

The two lines above this are:

RESP: [200] date: Fri, 29 Jan 2016 20:53:07 GMT content-length: 15 content-type: application/json x-compute-request-id: req-19d89d5a-f071-471f-9560-1f07d994146e
RESP BODY: {"servers": []}

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

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

Changed in python-cliff:
assignee: nobody → Doug Hellmann (doug-hellmann)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cliff (master)

Reviewed: https://review.openstack.org/279272
Committed: https://git.openstack.org/cgit/openstack/cliff/commit/?id=c96658875af585cfaf3aed9a60dc5f27d218241b
Submitter: Jenkins
Branch: master

commit c96658875af585cfaf3aed9a60dc5f27d218241b
Author: Doug Hellmann <email address hidden>
Date: Thu Feb 11 16:31:43 2016 -0500

    handle empty list in table formatter

    If there is no data to be formatted, don't try to make sure it fits in
    the width of the terminal because we're not going to be writing anything
    anyway.

    Closes-Bug: #1539770
    Change-Id: I877bad1be7a074fccc03f0327b0e43f1e125246c
    Signed-off-by: Doug Hellmann <email address hidden>

Changed in python-cliff:
status: In Progress → Fix Released
Akihiro Motoki (amotoki)
summary: - Empy set causing out of range error
+ Empty set causing out of range error
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/cliff 2.0.0

This issue was fixed in the openstack/cliff 2.0.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.