Bug 1392878 - Debug mode raises UnicodeDecodeError: 'utf8' codec can't decode byte 0x8d in position 7: invalid start byte
Summary: Debug mode raises UnicodeDecodeError: 'utf8' codec can't decode byte 0x8d in ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine-sdk-python
Classification: oVirt
Component: Core
Version: 4.0.2
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ovirt-4.0.6
: 4.0.4
Assignee: Ondra Machacek
QA Contact: Aleksei Slaikovskii
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-08 12:12 UTC by Ondra Machacek
Modified: 2017-01-18 07:29 UTC (History)
4 users (show)

Fixed In Version: python-ovirt-engine-sdk4-4.0.4
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-18 07:29:07 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-4.0.z+
lsvaty: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 66206 0 None MERGED Use COPYPOSTFIELDS for HTTP POST data 2021-01-26 21:43:44 UTC
oVirt gerrit 66255 0 None MERGED Use COPYPOSTFIELDS for HTTP POST data 2021-01-26 21:43:44 UTC

Description Ondra Machacek 2016-11-08 12:12:27 UTC
Description of problem:
When running Python SDK in debug mode, Python SDK raises following exception:

UnicodeDecodeError: 'utf8' codec can't decode byte 0x8d in position 7: invalid  start byte

Version-Release number of selected component (if applicable):
4.0.2

How reproducible:
always

Steps to Reproduce:
1. Run following script:

---------------------------------
import logging

import ovirtsdk4 as sdk
import ovirtsdk4.types as types

logging.basicConfig(level=logging.DEBUG, filename='example.log')

connection = sdk.Connection(
    url='https://engine.example.com/ovirt-engine/api',
    username='admin@internal',
    password='password',
    ca_file='ca.pem',
    debug=True,
    log=logging.getLogger(),
)

vms_service = connection.system_service().vms_service()
vms = vms_service.list()
connection.close()
---------------------------------

Actual results:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ovirtsdk4/__init__.py", line 637, in _curl_debug
    text = data.decode('utf-8') if type(data) == bytes else data
  File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xee in position 5: invalid continuation byte
Traceback (most recent call last):
  File "/tmp/list_vms.py", line 44, in <module>
    vms = vms_service.list()
  File "/usr/lib/python2.7/site-packages/ovirtsdk4/services.py", line 25275, in list
    response = self._connection.send(request)
  File "/usr/lib/python2.7/site-packages/ovirtsdk4/__init__.py", line 276, in send
    return self.__send(request)
  File "/usr/lib/python2.7/site-packages/ovirtsdk4/__init__.py", line 298, in __send
    self._sso_token = self._get_access_token()
  File "/usr/lib/python2.7/site-packages/ovirtsdk4/__init__.py", line 469, in _get_access_token
    sso_response['error']
ovirtsdk4.Error: Error during SSO authentication unsupported_grant_type : The authorization grant type is not supported by the authorization server.

Expected results:
Script successfully executed.

Additional info:

The problem is with pycurl version python-pycurl-7.19.0-17.el7.x86_64 and lower.
This problem was fixed in python-pycurl-7.19.0-18.el7.x86_64 tracked in following bug 1153321.

To support version python-pycurl-7.19.0-17 and lower we decided to fixed this problem using COPYPOSTFIELDS instead of POSTFIELDS to send HTTP POST data.


Note You need to log in before you can comment on or make changes to this bug.