Bug 1649284

Summary: Package.remote_location fails with AttributeError when using repository with baseurl
Product: [Fedora] Fedora Reporter: Jan Staněk <jstanek>
Component: dnfAssignee: Marek Blaha <mblaha>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: dmach, jmracek, jpokorny, mblaha, mhatina, packaging-team-maint, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.0.9-1.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-05 02:34: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: 1639827    
Bug Blocks:    
Attachments:
Description Flags
Simple reproducer script none

Description Jan Staněk 2018-11-13 10:24:53 UTC
Created attachment 1505187 [details]
Simple reproducer script

Description of problem:
When the method `remote_location()` is called on dnf.package.Package object retrieved from a dnf.repo.Repo configured with `baseurl`, it fails with `AttributeError: 'VectorString' object has no attribute 'decode'`.

See attached reproducer for details.


Version-Release number of selected component (if applicable):
dnf-4.0.4-2.fc29


How reproducible:
Always.

Steps to Reproduce:
1. Run reproducer script.

Actual results:
Traceback (most recent call last):
  File "reproducer.py", line 24, in <module>
    print("Remote location of", ARBITRARY_PKG_NAME, "is", pkg.remote_location())
  File "/usr/lib/python3.7/site-packages/dnf/package.py", line 248, in remote_location
    return schemes_filter([self.repo.baseurl])
  File "/usr/lib/python3.7/site-packages/dnf/package.py", line 231, in schemes_filter
    s = dnf.pycomp.urlparse.urlparse(url)[0]
  File "/usr/lib64/python3.7/urllib/parse.py", line 367, in urlparse
    url, scheme, _coerce_result = _coerce_args(url, scheme)
  File "/usr/lib64/python3.7/urllib/parse.py", line 123, in _coerce_args
    return _decode_args(args) + (_encode_result,)
  File "/usr/lib64/python3.7/urllib/parse.py", line 107, in _decode_args
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
  File "/usr/lib64/python3.7/urllib/parse.py", line 107, in <genexpr>
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
  File "/usr/lib64/python3.7/site-packages/libdnf/module.py", line 828, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, VectorString, name)
  File "/usr/lib64/python3.7/site-packages/libdnf/module.py", line 80, in _swig_getattr
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'VectorString' object has no attribute 'decode'


Expected results:
"Remote location of abcde is <URI>"

Comment 1 Marek Blaha 2018-11-13 13:06:53 UTC
PR https://github.com/rpm-software-management/dnf/pull/1264 fixes the error.

Comment 2 Jaroslav Mracek 2018-11-19 14:17:22 UTC
The problem is already fixed by https://github.com/rpm-software-management/dnf/commit/3d40275c0fd1a9781dafaefc9580ebf364ee9a6a.

Comment 3 Jaroslav Mracek 2018-11-21 13:35:23 UTC
*** Bug 1649898 has been marked as a duplicate of this bug. ***

Comment 4 Jaroslav Mracek 2018-11-22 13:50:17 UTC
*** Bug 1649898 has been marked as a duplicate of this bug. ***

Comment 5 Fedora Update System 2018-11-22 18:57:32 UTC
libdnf-0.22.3-1.fc29 dnf-4.0.9-1.fc29 dnf-plugins-core-4.0.2-1.fc29 dnf-plugins-extras-4.0.0-1.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-17cbc3c616

Comment 6 Fedora Update System 2018-11-23 02:57:04 UTC
dnf-4.0.9-1.fc29, dnf-plugins-core-4.0.2-1.fc29, dnf-plugins-extras-4.0.0-1.fc29, libdnf-0.22.3-1.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-17cbc3c616

Comment 7 Jan Pokorný [poki] 2018-11-23 09:57:01 UTC
Note that "tainted metadata" problem per [bug 1649898 comment 5] is
not addressed with an update to

  dnf-4.0.9-1.fc30.noarch
  dnf-plugins-core-4.0.2-1.fc30.noarch
  python3-dnf-4.0.9-1.fc30.noarch
  python3-dnf-plugins-core-4.0.2-1.fc30.noarch
  dnf-data-4.0.9-1.fc30.noarch
  libdnf-0.22.3-1.fc30.x86_64
  python3-hawkey-0.22.3-1.fc30.x86_64
  python3-libdnf-0.22.3-1.fc30.x86_64
  dnf-utils-4.0.2-1.fc30.noarch

(from
  dnf-4.0.4-2.fc30.noarch
  dnf-plugins-core-4.0.0-2.fc30.noarch
  python3-dnf-4.0.4-2.fc30.noarch
  python3-dnf-plugins-core-4.0.0-2.fc30.noarch
  dnf-data-4.0.4-2.fc30.noarch
  libdnf-0.22.0-8.fc30.x86_64
  python3-hawkey-0.22.0-8.fc30.x86_64
  python3-libdnf-0.22.0-8.fc30.x86_64
  dnf-utils-4.0.0-2.fc30.noarch
)

given that these two bugs are related at all, but since the other
bug was closed as a duplicate of this one, I assume so.

Command "dnf clean metadata" (or waiting for them to expire eventually?)
to the rescue, however that's not the expected user's convenience, IMHO.

Looks like an infrastructure for invalidating/cleaning metadata (e.g.
along the sketched lines) in cases like that is needed independently of
this very instance.

Comment 8 Fedora Update System 2018-12-05 02:34:36 UTC
dnf-4.0.9-1.fc29, dnf-plugins-core-4.0.2-1.fc29, dnf-plugins-extras-4.0.0-1.fc29, libdnf-0.22.3-1.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.