apport question will not accept multi-character responses

Bug #1722564 reported by Scott Moser on 2017-10-10
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Apport
Undecided
Unassigned
apport (Ubuntu)
Medium
Brian Murray
Xenial
Undecided
Unassigned
Artful
Medium
Brian Murray

Bug Description

=== Begin SRU Template ===
[Impact]
Packages which provide apport integration with more than 9 options in a choice will not be able to select options numbered >= 10 on the commandline using 'ubuntu-bug <package-name>'

[Test Case]
Overview:
 1. Update to proposed versions of cloud-init v. 17.1 and apport v. <X>
 2. Run 'ubuntu-bug cloud-init' attempt to report a bug on a cloud choice greater than 9
 3. View report and make sure the proper cloud is reported

Script:
if [ ! -f './lxc-proposed-snapshot' ]; then
  wget https://raw.githubusercontent.com/cloud-init/ubuntu-sru/master/bin/lxc-proposed-snapshot;
  chmod 755 lxc-proposed-snapshot;
fi

for release in xenial artful; do
        ref=$release-proposed;
        echo "$release START --------------";
        lxc-proposed-snapshot --proposed --publish $release $ref;
        lxc init $ref test-$release;
        lxc start test-$release;
        lxc exec test-$release -- apt install apport;
        lxc exec test-$release -- dpkg-query --show apport;
        lxc exec test-$release -- ubuntu-bug cloud-init;
done

[Regression Potential]
Minimal. This bug only affects packages with >9 bug filing options for a given choice. Worst case, is bugs filed would incorrectly represent option 1 of a selection instead of option 1X.

=== End SRU Template ===

=== original description ===
the newly added cloud-init apport support shows a list of cloud providers and asks the user to select one. There are currently 18 options. For any option > 10, apport will just take the '1' that is typed as the answer.

It should obviously wait for more than one character or a carriage return.

*** Please select the cloud vendor or environment in which this instance is running

Choices:
  1: Amazon - Ec2
  2: AliYun
  3: AltCloud
  4: Azure
  5: Bigstep
  6: CloudSigma
  7: CloudStack
  8: DigitalOcean
  9: GCE - Google Compute Engine
  10: MAAS
  11: NoCloud
  12: OpenNebula
  13: OpenStack
  14: OVF
  15: Scaleway
  16: SmartOS
  17: VMware
  18: Other
  C: Cancel
Please choose (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/C): 1

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: apport 2.20.7-0ubuntu2
ProcVersionSignature: Ubuntu 4.13.0-12.13-generic 4.13.3
Uname: Linux 4.13.0-12-generic x86_64
ApportVersion: 2.20.7-0ubuntu2
Architecture: amd64
Date: Tue Oct 10 15:21:48 2017
PackageArchitecture: all
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 LANG=C.UTF-8
SourcePackage: apport
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Scott Moser (smoser) wrote :
Brian Murray (brian-murray) wrote :

For reasons unknown to me apport-cli only reads one character.

 37 def raw_input_char(self, prompt):
 38 '''raw_input, but read only one character'''
 39
 40 sys.stdout.write(prompt)
 41 sys.stdout.write(' ')
 42 sys.stdout.flush()
 43
 44 file = sys.stdin.fileno()
 45 saved_attributes = termios.tcgetattr(file)
 46 attributes = termios.tcgetattr(file)
 47 attributes[3] = attributes[3] & ~(termios.ICANON)
 48 attributes[6][termios.VMIN] = 1
 49 attributes[6][termios.VTIME] = 0
 50 termios.tcsetattr(file, termios.TCSANOW, attributes)
 51
 52 try:
 53 ch = str(sys.stdin.read(1))
 54 finally:
 55 termios.tcsetattr(file, termios.TCSANOW, saved_attributes)
 56
 57 sys.stdout.write('\n')
 58 return ch

Changed in apport (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Scott Moser (smoser) on 2017-10-18
Changed in apport:
status: New → Confirmed
Chad Smith (chad.smith) wrote :

This quick fix worked on my side http://paste.ubuntu.com/25715415/
allows for two char reading if choices> 10

Brian Murray (brian-murray) wrote :

Thanks for looking at this Chad. Are the variable name changes, l to s, just to make things work better with ipdb?

Brian Murray (brian-murray) wrote :

Is the cloud-init apport hook being SRU'ed? If so then I'll also get an SRU for apport started.

Changed in apport (Ubuntu Artful):
status: Triaged → In Progress
assignee: nobody → Brian Murray (brian-murray)

An upload of apport to artful-proposed has been rejected from the upload queue for the following reason: "Could we, I dunno, have consistent behaviour regardless of input length and number of choices? This is about as user-friendly as something that's not very user-friendly.".

Chad Smith (chad.smith) wrote :

Ahh brian, sorry for this delay here, I forgot to subscribe to the bug. So those variable changes where actually because I had update apport on a zesty machine but accidentally diffed against xenial source. I'll put up an official upstream apport merge proposal and link it here so we can proceed with a discussion.

On Tue, Oct 24, 2017 at 03:35:57PM -0000, Chad Smith wrote:
> Ahh brian, sorry for this delay here, I forgot to subscribe to the bug.
> So those variable changes where actually because I had update apport on
> a zesty machine but accidentally diffed against xenial source. I'll put
> up an official upstream apport merge proposal and link it here so we can
> proceed with a discussion.

I hope to get back to this soon, but the SRU team rejected the change
because sometimes you'd have to enter just one character and sometimes
you'd have to enter a character and a space e.g. '3 ' if there were more
than 9 choices.

I've still no idea why the initial decision was made to accept only one
character.

--
Brian Murray

Chad Smith (chad.smith) wrote :

Yeah that feels like a premature optomization as that limits your interface options significantly (to only 9 valid choices). I'm suprised there haven't been any other bugs related to this, but maybe there aren't a lot of cli use-cases out there with complex bug-reporting choices.
I've attached a branch that now readlines instance or read(1) for prompts which contain a large set of choices (> 10).

This merge proposal a bit more flexible as it'd also permit options where > 99 choices are presented. I would think that > 99 choices would be a usability issues as I can't fathom people reading through 100+ separate options to actually choose the one that best applies to them.

I'm not sure the SRU team understood the impact of the branch. Per the pastebin that I provided originally, the user wouldn't have to input "3 " they would input "3<enter>" or "1<enter>" or "11".

I've since changes this branch to read until <enter> for all choices if the # or choices are > 10. This means that all existing apport use-cases retain the optimized 1 character choice selection if their provided choices are <= 9. For any lists larger than that (which is currently broken in apport) the user will have to hit enter after their choice.

Chad Smith (chad.smith) wrote :

Just tested on artful both above and below the prompt choice threshold of 10 and bug reporting works. Input of "9<enter>" for single digits choices versus "13<enter>" for multi-digit choices both work now for choice prompts with long lists. Short choice list prompts retain their single character responses.

tags: added: id-59ef68f44b84c4117299967c
Scott Moser (smoser) on 2017-11-02
Changed in apport (Ubuntu Artful):
importance: Medium → Low
importance: Low → Medium
Chad Smith (chad.smith) on 2017-11-09
description: updated

Hello Scott, or anyone else affected,

Accepted apport into artful-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apport/2.20.7-0ubuntu3.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-artful to verification-done-artful. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-artful. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in apport (Ubuntu Artful):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-artful
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.20.7-0ubuntu4

---------------
apport (2.20.7-0ubuntu4) bionic; urgency=medium

  * etc/apport/crashdb.conf: Enable Launchpad crash reports for bionic.
  * bin/apport-cli: read until <enter> instead of a single character when # of
    apport options is non-unique with a single character. Thanks to Chad Smith
    for the patch. (LP: #1722564)

 -- Brian Murray <email address hidden> Wed, 08 Nov 2017 12:18:04 -0800

Changed in apport (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers