Bug 1058975

Summary: TypeError: getattr(): attribute name must be string
Product: [Fedora] Fedora Reporter: Mark Hamzy <hamzy>
Component: createrepoAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: rawhideCC: fabrice, ignatenko, jzeleny, lmacken, packaging-team-maint, trailtotale
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: createrepo-0.10.3-1.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1091708 (view as bug list) Environment:
Last Closed: 2014-02-22 00:59:36 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:    
Bug Blocks: 1091708    

Description Mark Hamzy 2014-01-28 22:14:06 UTC
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

Comment 1 Zdeněk Pavlas 2014-01-29 09:13:45 UTC
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 2 Zdeněk Pavlas 2014-01-29 09:36:08 UTC
*** Bug 1056270 has been marked as a duplicate of this bug. ***

Comment 3 Igor Gnatenko 2014-02-07 07:24:42 UTC
(In reply to Zdeněk Pavlas from comment #1)
> 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
Could you push this update to Bodhi for f20 ?

Comment 4 Fedora Update System 2014-02-13 12:32:02 UTC
createrepo-0.10.3-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/createrepo-0.10.3-1.fc20

Comment 5 Fedora Update System 2014-02-14 08:10:46 UTC
Package createrepo-0.10.3-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing createrepo-0.10.3-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-2527/createrepo-0.10.3-1.fc20
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2014-02-22 00:59:36 UTC
createrepo-0.10.3-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 John Florian 2016-02-13 22:48:15 UTC
(In reply to Igor Gnatenko from comment #3)
> (In reply to Zdeněk Pavlas from comment #1)
> > 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
> Could you push this update to Bodhi for f20 ?


Any chance of getting this fix for EPEL too?  I just got bit by this with createrepo-0.9.9-23.el7.noarch and found the patch to be helpful, but would rather not worry about my patch getting squashed.