← Back to team overview

python-jenkins-developers team mailing list archive

[Bug 1775176] [NEW] use of locals() is picking up unencoded variables, breaking requests

 

Public bug reported:

Jenkins uses a few unicode characters in places likes node labels. In
our case, the labels exist in the function executing the request to get
the node configuration, but the use of 'locals()' is picking that up and
breaking on urllib:

      File "/opt/mita/src/mita/mita/util.py", line 341, in get_node_labels
        xml_configuration = _xml_configuration or conn.get_node_config(node_name)
      File "/opt/mita/local/lib/python2.7/site-packages/jenkins/__init__.py", line 1314, in get_node_config
        get_config_url = self._build_url(CONFIG_NODE, locals())
      File "/opt/mita/local/lib/python2.7/site-packages/jenkins/__init__.py", line 292, in _build_url
        url_path = format_spec % self._get_encoded_params(variables)
      File "/opt/mita/local/lib/python2.7/site-packages/jenkins/__init__.py", line 283, in _get_encoded_params
        params[k] = quote(v)
      File "/usr/lib/python2.7/urllib.py", line 1299, in quote
        return ''.join(map(quoter, s))
    KeyError: u'\u2018'


The commit that introduced this issue is: https://git.openstack.org/cgit/openstack/python-jenkins/commit/?id=827f28a223b03b4ffa025346081141cb1e6a5988

I would advise against the use of locals(), because it is tremendously
easy to cause undesired side-effects that are hard to detect (it took us
a while to understand where this character was coming from)

** Affects: python-jenkins
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1775176

Title:
  use of locals() is picking up unencoded variables, breaking requests

Status in Python Jenkins:
  New

Bug description:
  Jenkins uses a few unicode characters in places likes node labels. In
  our case, the labels exist in the function executing the request to
  get the node configuration, but the use of 'locals()' is picking that
  up and breaking on urllib:

        File "/opt/mita/src/mita/mita/util.py", line 341, in get_node_labels
          xml_configuration = _xml_configuration or conn.get_node_config(node_name)
        File "/opt/mita/local/lib/python2.7/site-packages/jenkins/__init__.py", line 1314, in get_node_config
          get_config_url = self._build_url(CONFIG_NODE, locals())
        File "/opt/mita/local/lib/python2.7/site-packages/jenkins/__init__.py", line 292, in _build_url
          url_path = format_spec % self._get_encoded_params(variables)
        File "/opt/mita/local/lib/python2.7/site-packages/jenkins/__init__.py", line 283, in _get_encoded_params
          params[k] = quote(v)
        File "/usr/lib/python2.7/urllib.py", line 1299, in quote
          return ''.join(map(quoter, s))
      KeyError: u'\u2018'

  
  The commit that introduced this issue is: https://git.openstack.org/cgit/openstack/python-jenkins/commit/?id=827f28a223b03b4ffa025346081141cb1e6a5988

  I would advise against the use of locals(), because it is tremendously
  easy to cause undesired side-effects that are hard to detect (it took
  us a while to understand where this character was coming from)

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1775176/+subscriptions


Follow ups