Bug 1304615 - TB when you try to enable non-existent copr project
Summary: TB when you try to enable non-existent copr project
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf-plugins-core
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Kadlčík
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1276932 1288960 1298246 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-04 07:55 UTC by Miroslav Suchý
Modified: 2016-07-21 13:28 UTC (History)
10 users (show)

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:
Clone Of:
Environment:
Last Closed: 2016-03-25 01:23:38 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miroslav Suchý 2016-02-04 07:55:04 UTC
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 07:55:56 UTC
Jakub, can you fix it please?

Comment 2 Parag Nemade 2016-02-04 08:48:14 UTC
Already reported in bug 1302235

Comment 3 Parag Nemade 2016-02-04 08:49:56 UTC
There is one more bug 1302232 to look related to this.

Comment 4 Jakub Kadlčík 2016-02-04 19:40:35 UTC
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 13:51:04 UTC
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 10:49:15 UTC
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 10:49:20 UTC
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 10:49:25 UTC
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 16:54:42 UTC
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 21:25:30 UTC
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 21:30:59 UTC
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-25 01:23:35 UTC
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 17:54:39 UTC
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 21:18:56 UTC
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 13:27:17 UTC
*** Bug 1288960 has been marked as a duplicate of this bug. ***

Comment 16 Igor Gnatenko 2016-07-21 13:27:25 UTC
*** Bug 1276932 has been marked as a duplicate of this bug. ***

Comment 17 Igor Gnatenko 2016-07-21 13:28:33 UTC
*** 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.