The records option gobbles up all trailing parameters

Bug #1736161 reported by Dr. Jens Harbott
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-designateclient
Fix Released
Undecided
Dr. Jens Harbott

Bug Description

Looking at the help output, the following commands should work fine, instead an error is raised:

openstack recordset create --type A --records 10.11.12.13 zone. test1.zone.
usage: openstack recordset create [-h] [-f {json,shell,table,value,yaml}]
                                  [-c COLUMN] [--max-width <integer>]
                                  [--fit-width] [--print-empty] [--noindent]
                                  [--prefix PREFIX] --records RECORDS
                                  [RECORDS ...] --type TYPE [--ttl TTL]
                                  [--description DESCRIPTION] [--all-projects]
                                  [--edit-managed]
                                  [--sudo-project-id SUDO_PROJECT_ID]
                                  zone_id name
openstack recordset create: error: too few arguments

In order for the command to succeed, the "--records" parameter needs to be the final parameter.

Changed in python-designateclient:
assignee: nobody → Dr. Jens Harbott (j-harbott)
status: New → In Progress
Revision history for this message
Dr. Jens Harbott (j-harbott) wrote :

So the "--records" option is defined with "nargs='+'", making it indeed use up any arguments that follow it. IMO this is very bad UI, the proper solution would be instead to use "action='append'" so that

a) the command as shown above would work, making it comply with what the help output indicates
b) one could still specify multiple records by repeating the "--records RECORD" option

The one question I'm not sure about is how we deal with backwards compatibility. One way of dealing is we say that this is so broken that we just fix it. More conservative approach would be to deprecate the "--records" option and add a new one, possibly called "--record" with the append action.

Revision history for this message
Graham Hayes (grahamhayes) wrote :

I like the idea of the move to multiple "--record" with "action='append'"

I think we should ping the OSC team to see what they have done in the past first though

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

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-designateclient (master)

Reviewed: https://review.openstack.org/526008
Committed: https://git.openstack.org/cgit/openstack/python-designateclient/commit/?id=66e4955408eacb4859cfef01a31d013e34c28ffb
Submitter: Zuul
Branch: master

commit 66e4955408eacb4859cfef01a31d013e34c28ffb
Author: Jens Harbott <email address hidden>
Date: Wed Dec 6 09:32:29 2017 +0000

    Improve recordset create UI

    The current implementation has '--records' as a quasi-positional
    argument, with the nargs='+' parameter it can only be used at the end of
    the command, which is confusing to users and doesn't comply with the
    help message.

    Add a new option '--record' that takes only exactly one record as
    parameter and can be repeated when multiple records are present.
    Deprecate the old option so it can be removed in the future.

    Change-Id: I8fefd9d0f104170d50c5d5dc3cbcc53facda9baf
    Closes-Bug: 1736161

Changed in python-designateclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-designateclient 2.8.0

This issue was fixed in the openstack/python-designateclient 2.8.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-designateclient (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/python-designateclient/+/904357

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/python-designateclient/+/904358

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-designateclient (master)

Reviewed: https://review.opendev.org/c/openstack/python-designateclient/+/904357
Committed: https://opendev.org/openstack/python-designateclient/commit/39423a98c51e3ed430218881ce1e9c669880bcb9
Submitter: "Zuul (22348)"
Branch: master

commit 39423a98c51e3ed430218881ce1e9c669880bcb9
Author: Takashi Kajinami <email address hidden>
Date: Wed Dec 27 02:13:51 2023 +0900

    Use --record instead of deprecated --records

    The --records argument was deprecated during queens cycle[1], and
    the new --record argument should be used.

    [1] 66e4955408eacb4859cfef01a31d013e34c28ffb

    Related-Bug: #1736161
    Change-Id: Ia4d84e6167d1192fee351d663af3e9f4cda1ea3f

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.opendev.org/c/openstack/python-designateclient/+/904358
Committed: https://opendev.org/openstack/python-designateclient/commit/4efec172d2ced30e51641d0161842986b2923440
Submitter: "Zuul (22348)"
Branch: master

commit 4efec172d2ced30e51641d0161842986b2923440
Author: Takashi Kajinami <email address hidden>
Date: Wed Dec 27 02:08:52 2023 +0900

    Recordset: Remove deprecated --records argument

    The --records argument was deprecated in 2.8.0[1], which was released
    during queens cycle. Multiple cycles have passed since then so we can
    remove these deprecated options now.

    [1] 66e4955408eacb4859cfef01a31d013e34c28ffb

    Related-Bug: #1736161
    Change-Id: Ic49d9b350a890d435b525bae611c8ba22cd29339

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.