python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

Updating `TaskDetails`-object makes `Task`-object undeleteable.

Open dekiesel opened this issue 1 year ago • 1 comments

Problem:

task=bucket.create_task("testtask")
taskdetails=task.get_details()
taskdetails.update(description="testdescription")
task.delete()

results in:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.12/site-packages/O365/planner.py", line 378, in delete
    response = self.con.delete(url, headers={'If-Match': self._etag})
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 941, in delete
    return self.oauth_request(url, 'delete', **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 887, in oauth_request
    return self._internal_request(self.session, url, method, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 848, in _internal_request
    raise HTTPError('{} | Error Message: {}'.format(e.args[0], error_message),
requests.exceptions.HTTPError: 409 Client Error: Conflict for url: https://graph.microsoft.com/v1.0/planner/tasks/JqRjj7vHKkS5QbddA3F_RJgAFjk9 | Error Message: The attempted changes conflicted with already accepted changes. Read the latest state and resolve differences.

Workaround Refresh the task object without actually changing it.


task.update(title=task.title)
task.delete()

It would be nice if updating the TaskDetails-object also would refresh the Task-object.

dekiesel avatar Jun 04 '24 12:06 dekiesel

PR are very welcome. If you have the time and know how to properly solve this I would be grateful if you submit a PR.

Thank

alejcas avatar Jun 14 '24 11:06 alejcas

@alejcas I can confirm this error occurs.

I think the only way the parent etag could be updated is by adding a call to re-retrieve the task. This is not necessarily what all users would need, and can be handled in the calling code when needed anyway. I'd suggest to leave the code as is.

RogerSelwyn avatar Apr 16 '25 11:04 RogerSelwyn

@alejcas I can confirm this error occurs.

I think the only way the parent etag could be updated is by adding a call to re-retrieve the task. This is not necessarily what all users would need, and can be handled in the calling code when needed anyway. I'd suggest to leave the code as is.

Ok, I'll close this then. Thanks

alejcas avatar Apr 22 '25 07:04 alejcas