Bug 1091708

Summary: TypeError: getattr(): attribute name must be string
Product: Red Hat Enterprise Linux 7 Reporter: Dan Horák <dhorak>
Component: createrepoAssignee: Valentina Mukhamedzhanova <vmukhame>
Status: CLOSED CURRENTRELEASE QA Contact: Eva Mrakova <emrakova>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.0CC: admiller, emrakova, fabrice, foraker1, hamzy, ignatenko, james.antill, jzeleny, lmacken, logan, packaging-team-maint, riehecky, slords, tgummels, woodard
Target Milestone: rc   
Target Release: 7.3   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1058975 Environment:
Last Closed: 2015-12-09 12:38:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1058975    
Bug Blocks: 1154205, 1178763, 1274917    

Description Dan Horák 2014-04-27 13:18:00 UTC
+++ This bug was initially created as a clone of Bug #1058975 +++

Running a private koji instance with createrepo-0.10.1-0.fc21.noarch
It is failing during regen-repo

I see the following:

$ /usr/libexec/kojid/mergerepos -a ppc64le -b /mnt/koji/repos/f21-build/9/ppc64le/blocklist -o /mnt/koji/tmp/tasks/15/15/repo -g /mnt/koji/repos/f21-build/9/groups/comps.xml -r file:///mnt/koji/tmp/tasks/15/15/repo_9_premerge/ -r http://9.5.211.49/ppc64le-minimal-packages/
Adding repo: file:///mnt/koji/tmp/tasks/15/15/repo_9_premerge/
Adding repo: http://9.5.211.49/ppc64le-minimal-packages/
pkg = acl-2.2.52-4.fc21.ppc64le, type (pkg) = <class 'yum.sqlitesack.YumAvailablePackageSqlite'>
__getitem__: key = 0, type (key) = <type 'int'>
Traceback (most recent call last):
  File "/usr/libexec/kojid/mergerepos", line 262, in <module>
    main(sys.argv[1:])
  File "/usr/libexec/kojid/mergerepos", line 257, in main
    merge.write_metadata()
  File "/usr/libexec/kojid/mergerepos", line 237, in write_metadata
    mdgen.doPkgMetadata()
  File "/usr/lib/python2.7/site-packages/createrepo/__init__.py", line 406, in doPkgMetadata
    if '://' in pkg: # remote
  File "/usr/lib/python2.7/site-packages/yum/packages.py", line 384, in __getitem__
    return getattr(self, key)
TypeError: getattr(): attribute name must be string


It is from the following code:

[root@localhost ~]# cat /usr/lib/python2.7/site-packages/createrepo/__init__.py
...
            for pkg in self.conf.pkglist:
                self.callback.log("pkg = %s, type (pkg) = %s" % (pkg, type (pkg)))
                if "://" in pkg: # remote
...

[root@localhost ~]# cat /usr/lib/python2.7/site-packages/yum/packages.py
...
    def __getitem__(self, key):
        print "__getitem__: key = %s, type (key) = %s" % (key, type (key))
        return getattr(self, key)
...


It looks like Python is in a loop trying to enumerate the keys given that it has passed a 0 integer.

Is that code correct?  You are trying to use "in" for a substring test but relying on __getitem__ which is doing a member variable lookup.

http://docs.python.org/2/reference/datamodel.html#object.__contains__
http://docs.python.org/2/reference/expressions.html#membership-test-details

--- Additional comment from Zdeněk Pavlas on 2014-01-29 04:13:45 EST ---

Hi, thanks for the report!

"if '://' in pkg:" is correct under the normal use of the pkglist option, but I've missed that passing in a package sack was kind of supported too. (Although not documented, and --update didn't apparently work anyway).  Adding the early file checks broke this.  Fixed upstream.

http://createrepo.baseurl.org/gitweb?p=createrepo.git;a=commitdiff;h=b8904f59773a478aedd416963ec451c678a6bb72

Comment 1 Dan Horák 2014-04-27 13:19:21 UTC
The crash happens also with createrepo-0.9.9-23.el7.noarch, the upstream fix above resolves the problem also with 0.9.9

Comment 5 Karel Srot 2015-12-02 11:54:06 UTC
*** Bug 1219607 has been marked as a duplicate of this bug. ***