Bug 1444016 - Bad check of return code
Summary: Bad check of return code
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine-sdk-python
Classification: oVirt
Component: General
Version: 4.1.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-4.1.3
: 4.1.4
Assignee: Ondra Machacek
QA Contact: Petr Matyáš
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-04-20 12:39 UTC by Fabrice Bacchella
Modified: 2017-07-06 14:04 UTC (History)
5 users (show)

Fixed In Version: python-ovirt-engine-sdk4-4.1.4
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-06 14:04:54 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-4.1+
lsvaty: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 75755 0 master MERGED Check content type only when really needed 2017-05-04 13:32:16 UTC
oVirt gerrit 76460 0 sdk_4.1 MERGED Check content type only when really needed 2017-05-04 14:28:13 UTC

Description Fabrice Bacchella 2017-04-20 12:39:50 UTC
I'm running the python sdk 4.1.3 again a ovirt instance release 4.0.4.4-1.el7.centos.

I tried to run the sample code https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/get_display_ticket.py but it fails with the message :

    Entity: line 1: parser error : Extra content at the end of the document
    ^

And looking in the example.log, I got :
DEBUG:root:POST /ovirt-engine/api/vms/61a6de0a-2a21-4e90-bc20-29e3f0cd0ad8/graphicsconsoles/7370696365/ticket HTTP/1.1
....
DEBUG:root:HTTP/1.1 404 Not Found


I think i was hit by https://bugzilla.redhat.com/show_bug.cgi?id=1383342. So the failure is not a problem. But I got a meaningless error message. The code got a 404, so why didn't it say so, and instead throws me a message about something else ?

Comment 1 Juan Hernández 2017-04-20 15:24:01 UTC
The meaningless error message is a side effect of the combination of bug 1383342 and bug 1440292. In that situation the server returns an HTML error message and we don't check the returned content type, hence we try to parse the HTML as XML, and that is the error that generates.

In a normal situation the SDK returns a more reasonable error message, for example, if you do this:

  vm_service = vms_service.vm_service('doesnotexist')
  vm_service.get()

You get this exception:

  Traceback (most recent call last):
    File "...py", line 41, in <module>
      vm_service.get()
    File ".../ovirtsdk4/services.py", line 29565, in get
      self._check_fault(response)
    File ".../ovirtsdk4/service.py", line 98, in _check_fault
      Service._raise_error(response, fault)
    File ".../ovirtsdk4/service.py", line 71, in _raise_error
      raise Error(msg)
  ovirtsdk4.Error: HTTP response code is 404.

Consider closing this as a duplicate of bug 1440292. Note also that the fix for that bug, isn't complete yet, see the details. I am moving it back to ASSIGNED.

Comment 2 Ondra Machacek 2017-04-20 15:46:32 UTC
It's version 4.1.3, so there shouldn't be any content-type checking yet, but the issue is that we miss the checking of response code in action methods. Anyway, I will send a fix for both.

Comment 3 Petr Matyáš 2017-06-02 13:27:17 UTC
Verified on 4.1.3-2


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