Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing update_config when the xml contains Chinese will report an error #841

Open
typ431127 opened this issue Apr 26, 2023 · 1 comment

Comments

@typ431127
Copy link

ISSUE TYPE
  • Bug Report
Jenkinsapi VERSION

0.3.11

Jenkins VERSION

2.190.3

SUMMARY

Executing update_config when the xml contains Chinese will report an error

EXPECTED RESULTS
ACTUAL RESULTS
USEFUL INFORMATION

job.py Adding decode can solve this problem

 response = self.jenkins.requester.post_url(url, params={}, data=config.encode("utf-8"))
Traceback (most recent call last):
  File "C:/Users/15006/Desktop/py_work/2022/jk.py", line 135, in <module>
    J[job].update_config(xmlconfig)
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jenkinsapi\job.py", line 605, in update_config
    response = self.jenkins.requester.post_url(url, params={}, data=config)
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jenkinsapi\utils\requester.py", line 155, in post_url
    return self.session.post(self._update_url_scheme(url), **requestKwargs)
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\requests\sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\15006\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1277, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1322, in _send_request
    body = _encode(body, 'body')
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 174, in _encode
    (name.title(), data[err.start:err.end], name)) from None
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 487-491: Body ('渡渡鸟机器人') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.
@LeoHsiao1
Copy link

Hi
This issue has been fixed. #840
However jenkinsapi has not yet released a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants