jesper-raemaekers / python-polarion

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

Getting linked items fails with deleted items #138

Closed mrtnnwmn closed 9 months ago

mrtnnwmn commented 1 year ago

I'm using getLinkedItemWithRoles() and on a particular work item I get the error below:

    470 if self.linkedWorkItemsDerived is not None:
    471     for linked_item in self.linkedWorkItemsDerived.LinkedWorkItem:
--> 472         linked_items.append((linked_item.role.id, Workitem(self._polarion, self._project, uri=linked_item.workItemURI)))
    473 return linked_items

AttributeError: 'NoneType' object has no attribute 'id'

Looking at the work item in Polarion it seems that there are links to two items that have been deleted, so I assume the method is failing when it attempts to add the deleted items to the linked work items list. Could you add a check for work item validity?

jesper-raemaekers commented 1 year ago

I was not able to reproduce it, but I added a check that should solve this exception.

github-actions[bot] commented 12 months ago

This issue is stale because it has been open for 30 days with no activity.

alexandertoepfer commented 12 months ago

I have had the same issue, it happens because links in polarion do not guarantee the workitem exists, I would advise to check in your system for such dangling links, otherwise you can always hack "try: ... except: continue" around the list append.

Edit: If you do need more info to reproduce this, I'll be glad to help provide more insights

jesper-raemaekers commented 11 months ago

I think this happens when items are deleted using the API. it seems that the GUI of Polarion also cleans up all references, but this may not be the case for the API. Did @z3r0k3ys experience this issue with the latest package version?

alexandertoepfer commented 11 months ago

I will be able to provide an answer by Monday, because unfortunately I'm using a forked version with the try except block to avoid this issue, but I can guarantee the problem is not the package, it's rather that those references are allowed to exist in the first place, which should be addressed by polarion

alexandertoepfer commented 11 months ago

You could add a flag for safety to turn missing items into just a warning, but from my point of view this can be closed

github-actions[bot] commented 10 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 9 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.