sudo apt-add-repository ppa: results in IndexError: string index out of range

Bug #1405950 reported by Hans Joachim Desserud
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
One Hundred Papercuts
Fix Released
High
Unassigned
software-properties (Ubuntu)
Fix Released
High
Unassigned

Bug Description

$ sudo apt-add-repository ppa
Error: 'ppa' invalid

Just saying ppa without a user- or ppa name fails gracefully and informs the user it doesn't work. However, if we add the ':' separator, it attempts and fails to parse the string:

$ sudo apt-add-repository ppa:
Traceback (most recent call last):
  File "/usr/bin/apt-add-repository", line 119, in <module>
    shortcut = shortcut_handler(line)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 837, in shortcut_handler
    ret = factory(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 382, in shortcut_handler
    return PPAShortcutHandler(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 345, in __init__
    self.shortcut = mangle_ppa_shortcut(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 133, in mangle_ppa_shortcut
    if (user[0] == "~"):
IndexError: string index out of range

This should handle the error more gracefully and display a similar error message to the user as above.

(See also bug 1405951 which is unrelated but similar)

ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: software-properties-common 0.96.1
ProcVersionSignature: Ubuntu 3.16.0-28.38-generic 3.16.7-ckt1
Uname: Linux 3.16.0-28-generic x86_64
ApportVersion: 2.15.1-0ubuntu1
Architecture: amd64
CurrentDesktop: Unity
Date: Sat Dec 27 15:06:46 2014
InstallationDate: Installed on 2014-12-19 (7 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Alpha amd64 (20141211)
PackageArchitecture: all
SourcePackage: software-properties
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Hans Joachim Desserud (hjd) wrote :
description: updated
Revision history for this message
incognito (prostovrn) wrote :

On Ubuntu14.10 with latest update I have the same error

# apt-add-repository ppa:
Traceback (most recent call last):
  File "/usr/bin/apt-add-repository", line 119, in <module>
    shortcut = shortcut_handler(line)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 839, in shortcut_handler
    ret = factory(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 382, in shortcut_handler
    return PPAShortcutHandler(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 345, in __init__
    self.shortcut = mangle_ppa_shortcut(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 133, in mangle_ppa_shortcut
    if (user[0] == "~"):
IndexError: string index out of range

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Thanks for testing. :) I'm marking this confirmed since you were able to trigger the same problem.

Unrelated, note that 14.10 has now reached end of life, so you probably want to upgrade to 15.04 when you have the opportunity.

Changed in software-properties (Ubuntu):
status: New → Confirmed
Changed in software-properties (Ubuntu):
importance: Undecided → Medium
importance: Medium → High
Changed in hundredpapercuts:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Interesting, there must be a fix out there somewhere - but so far I find it rather unclear where it is included.

On Ubuntu 14.04.3 LTS with software-properties-common 0.92.37.5 it works in the requested way:
=> sudo apt-add-repository ppa:
Cannot add PPA: 'ppa:'.
Please check that the PPA name or format is correct.

But on 15.10 beta2 with software-properties-common 0.96.10 it fails as described before.

Need to dig through the repositories ...

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

This code went through several major overhauls, so I won't try to fix them all.
As I already stated the last LTS 14.04.3 is already fine.

I provide a patch just for the most recent - currently being upstream/wily which should ensure the issue doesn't come back once more.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "gracefully handle empty ppa spec" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package software-properties - 0.96.13

---------------
software-properties (0.96.13) wily; urgency=medium

  * Properly parse a ppa which has a leading slash, something which a lot of
    people seem use as an argument to add-apt-repository. (LP: #1426933)

 -- Brian Murray <email address hidden> Tue, 13 Oct 2015 11:31:14 -0700

Changed in software-properties (Ubuntu):
status: Confirmed → Fix Released
Changed in hundredpapercuts:
status: Confirmed → Fix Released
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.