get_jobs fails when space in folder name

Bug #1698815 reported by Andrew
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Python Jenkins
Fix Released
Undecided
Andrew Mellen

Bug Description

With cloudbees folders if you have a folder with a space in it, you will get the following error

>>> server = jenkins.Jenkins('http://jenkinsmaster', username='username', password='password')

>>> server.get_jobs(folder_depth=2)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jenkins/__init__.py", line 551, in get_info
    Request(self._build_url(url))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jenkins/__init__.py", line 431, in jenkins_open
    response = urlopen(req, timeout=self.timeout).read()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jenkins/__init__.py", line 765, in get_jobs
    return self.get_all_jobs(folder_depth=folder_depth)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jenkins/__init__.py", line 825, in get_all_jobs
    query=JOBS_QUERY)['jobs']))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jenkins/__init__.py", line 555, in get_info
    % self.server)
jenkins.BadHTTPException: Error communicating with server[http://jenkinsmaster]

Revision history for this message
Andrew Mellen (mellena1) wrote :

I have a fix for this, but I'm having trouble using tox to test it. I've never contributed on OpenStack projects before so I'm a bit out of my element.

Andrew Mellen (mellena1)
Changed in python-jenkins:
assignee: nobody → Andrew Mellen (mellena1)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-jenkins (master)

Fix proposed to branch: master
Review: https://review.openstack.org/504536

Changed in python-jenkins:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-jenkins (master)

Reviewed: https://review.openstack.org/504536
Committed: https://git.openstack.org/cgit/openstack/python-jenkins/commit/?id=16007e01858cc5d36afdc31d22b5644f91a1f935
Submitter: Zuul
Branch: master

commit 16007e01858cc5d36afdc31d22b5644f91a1f935
Author: Andrew Mellen <email address hidden>
Date: Fri Sep 15 18:46:35 2017 -0400

    Sanitize url in get_info() function

    Change-Id: I540f6d636e277d0ad230f844d2db6220edfb672f
    Closes-Bug: #1698815

Changed in python-jenkins:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.