Bug 1706409

Summary: osc fails with exception, if https_proxy environment variable is set [PATCH available]
Product: [Fedora] Fedora Reporter: Fritz Elfert <fritz>
Component: oscAssignee: Haïkel Guémar <karlthered>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 29CC: karlthered, msuchy, ngompa13
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: osc-0.165.1-255.1.2.fc30 osc-0.165.1-255.1.2.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-01 00:52:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
This patch fixes the bug none

Description Fritz Elfert 2019-05-04 16:57:17 UTC
User-Agent:       Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0
Build Identifier: 

If https_proxy is set AND I run an osc command that actually attempts to fetch some package metadata (like "osc r") then osc fails wit the following backtrace:

[felfert@floh opennx]$ osc r
Traceback (most recent call last):
  File "/usr/bin/osc", line 41, in <module>
    r = babysitter.run(osccli)
  File "/usr/lib/python2.7/site-packages/osc/babysitter.py", line 61, in run
    return prg.main(argv)
  File "/usr/lib/python2.7/site-packages/osc/cmdln.py", line 344, in main
    return self.cmd(args)
  File "/usr/lib/python2.7/site-packages/osc/cmdln.py", line 367, in cmd
    retval = self.onecmd(argv)
  File "/usr/lib/python2.7/site-packages/osc/cmdln.py", line 501, in onecmd
    return self._dispatch_cmd(handler, argv)
  File "/usr/lib/python2.7/site-packages/osc/cmdln.py", line 1232, in _dispatch_cmd
    return handler(argv[0], opts, *args)
  File "/usr/lib/python2.7/site-packages/osc/commandline.py", line 5245, in do_results
    get_results(**kwargs)
  File "/usr/lib/python2.7/site-packages/osc/core.py", line 5740, in get_results
    for results in get_package_results(apiurl, project, package, **kwargs):
  File "/usr/lib/python2.7/site-packages/osc/core.py", line 5795, in get_package_results
    xml = b''.join(show_results_meta(apiurl, project, package, *args, **kwargs))
  File "/usr/lib/python2.7/site-packages/osc/core.py", line 5673, in show_results_meta
    f = http_GET(u)
  File "/usr/lib/python2.7/site-packages/osc/core.py", line 3387, in http_GET
    def http_GET(*args, **kwargs):    return http_request('GET', *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/osc/core.py", line 3376, in http_request
    fd = urlopen(req, data=data)
  File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib64/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/site-packages/osc/oscssl.py", line 201, in https_open
    request_uri = urldefrag(full_url)[0]
NameError: global name 'urldefrag' is not defined

Reproducible: Always

Steps to Reproduce:
1. set https_proxy e.g. export https_proxy=http://192.168.2.17:3128/
2. cd into a previously checked-out OBS package directory
3. run osc r to show build status on OBS
Actual Results:  
The above exception is thrown

Expected Results:  
Output of the actual build status

Comment 1 Fritz Elfert 2019-05-04 17:39:06 UTC
Created attachment 1563382 [details]
This patch fixes the bug

Comment 2 Fedora Update System 2019-05-31 01:38:45 UTC
FEDORA-2019-18146b9cfb has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-18146b9cfb

Comment 3 Fedora Update System 2019-05-31 01:38:45 UTC
FEDORA-2019-0d78e279d7 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-0d78e279d7

Comment 4 Fedora Update System 2019-06-01 00:52:22 UTC
osc-0.165.1-255.1.2.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 5 Fedora Update System 2019-06-01 04:02:28 UTC
osc-0.165.1-255.1.2.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.