Bug 1730244 - Yum commands fails with "IndexError: tuple index out of range"
Summary: Yum commands fails with "IndexError: tuple index out of range"
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: yum
Version: 7.6
Hardware: All
OS: Linux
Target Milestone: rc
: 7.8
Assignee: Packaging Maintenance Team
QA Contact: BaseOS QE Security Team
Depends On:
TreeView+ depends on / blocked
Reported: 2019-07-16 09:37 UTC by Christophe Besson
Modified: 2019-10-31 13:40 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2019-07-18 13:16:18 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 4284051 0 Troubleshoot None Yum commands fails with "IndexError: tuple index out of range" 2019-07-16 14:16:00 UTC

Description Christophe Besson 2019-07-16 09:37:30 UTC
Description of problem:

There is a MalformedURIError which isn't caught explicitly by the yum-cli.py python code, in the function getOptionsConfig(). Instead, it is caught by the yum.errors.ConfigError exception, which fails to print an error message with this input value.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Modify the directive serverURL from /etc/sysconfig/rhn/up2date with a malformed URL. For example, a missing semi-colon (:) or an empty value leads to this error.
2. Execute any yum command.

Actual results:
# yum update
Loaded plugins: enabled_repos_upload, fastestmirror, package_upload, product-id, rhnplugin, search-disabled-repos, subscription-manager
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 375, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 170, in main
  File "/usr/share/yum-cli/cli.py", line 283, in getOptionsConfig
    e = '%s: %s' % (to_unicode(e.args[1]), repr(e.filename))
IndexError: tuple index out of range
Uploading Enabled Repositories Report
Loaded plugins: fastestmirror, product-id, rhnplugin, subscription-manager
Unable to upload Enabled Repositories Report

Expected results:

Currently, it is difficult to identify the issue, since printing the error message caught itself an exception. We can expect an output looking like:

# yum update
Loaded plugins: changelog, fs-snapshot, priorities, refresh-packagekit, rhnplugin, rpm-warm-cache, verify
Config error: missing protocol in uri

Additional info:
The following patch works for me:

--- /usr/share/yum-cli/cli.py	2018-08-15 12:10:25.000000000 -0400
+++ /usr/share/yum-cli/cli.py.new	2019-07-16 05:21:57.087669646 -0400
@@ -47,6 +47,7 @@
 import yumcommands
 from yum.i18n import to_unicode, to_utf8, exception2msg
+from rhn.rpclib import MalformedURIError
 #  This is for yum-utils/yumdownloader in RHEL-5, where it isn't importing this
 # directly but did do "from cli import *", and we did have this in 3.2.22. I
@@ -279,6 +280,9 @@
         except yum.Errors.ConfigError, e:
             self.logger.critical(_('Config error: %s'), e)
+        except MalformedURIError, e:
+            self.logger.critical(_('Config error: %s'), e)
+            sys.exit(1)
         except IOError, e:
             e = '%s: %s' % (to_unicode(e.args[1]), repr(e.filename))
             self.logger.critical(_('Config error: %s'), e)

Note You need to log in before you can comment on or make changes to this bug.