jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
57 stars 35 forks source link

exception when retrieving a workitem from the server #24

Closed ergorion closed 3 years ago

ergorion commented 3 years ago

I know that this workitem exists, I can look at it in the web userinterface. However, when I try to get it, I get an exception. In addition, this breaks my search with projet.searchWorkitemFullItem() -- as the function also fetches all workitems from the server. When it tries to retrieve this problematic work item, the exception breaks the complete search.

wi = project.getWorkitem(workitemid)
Traceback (most recent call last):

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\workitem.py", line 52, in __init__
    self._polarion_item = service.getWorkItemById(

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\proxy.py", line 46, in __call__
    return self._proxy._binding.send(

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 135, in send
    return self.process_reply(client, operation_obj, response)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 229, in process_reply
    return self.process_error(doc, operation)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 329, in process_error
    raise Fault(

Fault: java.lang.ClassCastException: class com.polarion.platform.persistence.ipi.WeakPObjectList cannot be cast to class com.polarion.platform.persistence.IEnumOption (com.polarion.platform.persistence.ipi.WeakPObjectList and com.polarion.platform.persistence.IEnumOption are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @631cb129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "<ipython-input-27-2ad334da8ced>", line 1, in <module>
    wi = project.getWorkitem(<id>)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\project.py", line 69, in getWorkitem
    return Workitem(self.polarion, self, id)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\workitem.py", line 55, in __init__
    raise Exception(

Exception: Cannot find workitem <id> in project <projectname>
jesper-raemaekers commented 3 years ago

I think it's not possible to trace why this happens, but maybe we the solution is then to catch the exception in the searchWorkitemFullItem method and just omit that result.

Would that be acceptable?

ergorion commented 3 years ago

I agree that it's not possible to trace/avoid this, it seems to happen on the server side. I have tried a different approach: instead of omitting the result (could be one, could be more), my solution breaks the method searchWorkitemFullItem into a new searchWorkitem that only returns the ids (as default), and then the rest functionality to fetch each workitem completely.

Maybe you would like to check out my modified branch? In addition, I added support for approvees (trying to hang on to your style as much as possible). If you like the change, feel free to take it over, I do not want to start a seperate project/branch.

jesper-raemaekers commented 3 years ago

I took your solution, made the tests and some improvements. Thanks for the contribution. Feel free to re-open if you find any issues. This will be released after i fix up the other open issues :)