Table formatter doesn't support empty list

Bug #1546332 reported by Cedric Brandily
This bug report is a duplicate of:  Bug #1539770: Empty set causing out of range error. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cliff
In Progress
Undecided
Cedric Brandily

Bug Description

Table formatter is not able to handle empty list (other formatters support it) in cliff 1.17.0 because it tries to visit the first element of an empty list.

Typical example with neutronclient:

neutron port-list --json
[]

neutron --debug port-list
Traceback (most recent call last):
  File "/home/T0102996/projects/os/neutronclient/neutronclient/shell.py", line 826, in run_subcommand
    return run_command(cmd, cmd_parser, sub_argv)
  File "/home/T0102996/projects/os/neutronclient/neutronclient/shell.py", line 106, in run_command
    return cmd.run(known_args)
  File "/home/T0102996/projects/os/neutronclient/.tox/py27/local/lib/python2.7/site-packages/cliff/display.py", line 88, in run
    self.produce_output(parsed_args, column_names, data)
  File "/home/T0102996/projects/os/neutronclient/.tox/py27/local/lib/python2.7/site-packages/cliff/lister.py", line 51, in produce_output
    parsed_args,
  File "/home/T0102996/projects/os/neutronclient/.tox/py27/local/lib/python2.7/site-packages/cliff/formatters/table.py", line 64, in emit_list
    stdout, x, int(parsed_args.max_width), min_width)
  File "/home/T0102996/projects/os/neutronclient/.tox/py27/local/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
list index out of range

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/280982

Changed in python-cliff:
assignee: nobody → Cedric Brandily (cbrandily)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on cliff (master)

Change abandoned by Cedric Brandily (<email address hidden>) on branch: master
Review: https://review.openstack.org/280982

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.