Bug 1304615 - TB when you try to enable non-existent copr project
TB when you try to enable non-existent copr project
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: dnf-plugins-core (Show other bugs)
23
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Kadlčík
Fedora Extras Quality Assurance
:
: 1276932 1288960 1298246 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-04 02:55 EST by Miroslav Suchý
Modified: 2016-07-21 09:28 EDT (History)
10 users (show)

See Also:
Fixed In Version: dnf-plugins-core-0.1.19-1.fc23 dnf-plugins-core-0.1.19-1.fc24 dnf-plugins-core-0.1.19-1.fc22
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-03-24 21:23:38 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Miroslav Suchý 2016-02-04 02:55:04 EST
Description of problem:
TB when you try to enable non-existent copr project.

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


How reproducible:
deterministic

Steps to Reproduce:
1. dnf copr enable @copr/xxjkhalkjhlkj fedora-23-x86_64

Actual results:
...
Do you want to continue? [y/N]: y
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/dnfpluginscore/lib.py", line 71, in urlopen
    librepo.download_url(url, fo.fileno(), handle)
  File "/usr/lib64/python3.4/site-packages/librepo/__init__.py", line 1517, in download_url
    return _librepo.download_url(handle, url, fd)
librepo.LibrepoException: (10, 'Status code: 404 for http://copr-fe-dev.cloud.fedoraproject.org/coprs/@copr/kjhgkjhgkjh/repo/fedora-23/', 'Error HTTP/FTP status code')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/dnf-plugins/copr.py", line 264, in _download_repo
    f = dnfpluginscore.lib.urlopen(self, None, self.copr_url + api_path, 'w+')
  File "/usr/lib/python3.4/site-packages/dnfpluginscore/lib.py", line 73, in urlopen
    raise IOError(e.args[1])
OSError: Status code: 404 for http://copr-fe-dev.cloud.fedoraproject.org/coprs/@copr/kjhgkjhgkjh/repo/fedora-23/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/dnf", line 57, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 174, in user_main
    errcode = main(args)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 60, in main
    return _main(base, args)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 112, in _main
    cli.run()
  File "/usr/lib/python3.4/site-packages/dnf/cli/cli.py", line 1095, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python3.4/site-packages/dnf-plugins/copr.py", line 153, in run
    self._download_repo(project_name, repo_filename, chroot)
  File "/usr/lib/python3.4/site-packages/dnf-plugins/copr.py", line 272, in _download_repo
    res = urllib.request.urlopen(self.copr_url + "/coprs/" + project_name, 'w+')
  File "/usr/lib64/python3.4/urllib/request.py", line 161, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.4/urllib/request.py", line 461, in open
    req = meth(req)
  File "/usr/lib64/python3.4/urllib/request.py", line 1112, in do_request_
    raise TypeError(msg)
TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
Comment 1 Miroslav Suchý 2016-02-04 02:55:56 EST
Jakub, can you fix it please?
Comment 2 Parag Nemade 2016-02-04 03:48:14 EST
Already reported in bug 1302235
Comment 3 Parag Nemade 2016-02-04 03:49:56 EST
There is one more bug 1302232 to look related to this.
Comment 4 Jakub Kadlčík 2016-02-04 14:40:35 EST
The line causing this problem is

res = urllib.request.urlopen(self.copr_url + "/coprs/" + project_name, 'w+')
status_code = res.getcode()

Here: https://github.com/rpm-software-management/dnf-plugins-core/blob/8261eb9a060b0cbf57d82b4f94291242a4b233ec/plugins/copr.py#L272

Syntax for urlopen is urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None) 

so the 'w+' in our code is passed as `data` argument. Issue is that `data` can't be string, therefore it fails and solution would be encoding it. I can do that, but first, I want to ask Mirek. What is the purpose of 'w+' in this code? Do we really want to send 'w+' in data, or is it just a typo?

I suspect that it could happen by copying some usage of dnfpluginscore.lib.urlopen(...., 'w+') 

Thanks
Comment 5 Jakub Kadlčík 2016-03-21 09:51:04 EDT
This issue have origins in 1267808. In order to solve it, Honza Horak proposed a patch containing:

-        f = dnfpluginscore.lib.urlopen(self, None, api_url)
+        f = dnfpluginscore.lib.urlopen(self, None, api_url, "w+")

which was modified and applied in aff262d. Unfortunately in this commit were changed even this lines:


-    res = urllib.request.urlopen(self.copr_url + "/coprs/" + project_name)
+    res = urllib.request.urlopen(self.copr_url + "/coprs/" + project_name, 'w+')

and

-    res = urllib.urlopen(self.copr_url + "/coprs/" + project_name)
+    res = urllib.urlopen(self.copr_url + "/coprs/" + project_name, 'w+')


I am sending following PR to fix it: https://github.com/rpm-software-management/dnf-plugins-core/pull/149
Comment 6 Fedora Update System 2016-03-22 06:49:15 EDT
dnf-plugins-core-0.1.19-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-d8b69dc579
Comment 7 Fedora Update System 2016-03-22 06:49:20 EDT
dnf-plugins-core-0.1.19-1.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-c0777f4cf3
Comment 8 Fedora Update System 2016-03-22 06:49:25 EDT
dnf-plugins-core-0.1.19-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-adcfaafc5c
Comment 9 Fedora Update System 2016-03-22 12:54:42 EDT
dnf-plugins-core-0.1.19-1.fc24 has been pushed to the Fedora 24 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-2016-c0777f4cf3
Comment 10 Fedora Update System 2016-03-22 17:25:30 EDT
dnf-plugins-core-0.1.19-1.fc22 has been pushed to the Fedora 22 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-2016-adcfaafc5c
Comment 11 Fedora Update System 2016-03-22 17:30:59 EDT
dnf-plugins-core-0.1.19-1.fc23 has been pushed to the Fedora 23 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-2016-d8b69dc579
Comment 12 Fedora Update System 2016-03-24 21:23:35 EDT
dnf-plugins-core-0.1.19-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
Comment 13 Fedora Update System 2016-03-26 13:54:39 EDT
dnf-plugins-core-0.1.19-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.
Comment 14 Fedora Update System 2016-03-30 17:18:56 EDT
dnf-plugins-core-0.1.19-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.
Comment 15 Igor Gnatenko 2016-07-21 09:27:17 EDT
*** Bug 1288960 has been marked as a duplicate of this bug. ***
Comment 16 Igor Gnatenko 2016-07-21 09:27:25 EDT
*** Bug 1276932 has been marked as a duplicate of this bug. ***
Comment 17 Igor Gnatenko 2016-07-21 09:28:33 EDT
*** Bug 1298246 has been marked as a duplicate of this bug. ***

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