Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deletion of task has no effect #83

Open
haegar33 opened this issue Dec 16, 2022 · 2 comments
Open

deletion of task has no effect #83

haegar33 opened this issue Dec 16, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@haegar33
Copy link

haegar33 commented Dec 16, 2022

Bug description

using the api.delete_task() function reports success but task are still present

Expected behaviour

when executing the api.delete_task() twice I would expect an error for the second call as task should be already deleted

Is reproducible

Yes

To reproduce

Code Snipplet:

from todoist_api_python.api import TodoistAPI
api = TodoistAPI(key)

I receive a list of completed task via the REST API as this does not work with the python module. I get a python dict clist, then:

  for c in clist:
        print('Delete item: ',c['content'],c['task_id'])
        try:
            is_success = api.delete_task(task_id=c['task_id'])
            print(is_success)
        except Exception as error:
            print(error)

works fine, but when I run the script a second time all "deleted" tasks are back again

Version information:

  • Package version: 8.1.3
  • Python version: 3.10

Additional information

@haegar33 haegar33 added the bug Something isn't working label Dec 16, 2022
@haegar33
Copy link
Author

actually the problem is not for the python module but for all API calls! Whether using the Sync V9 or REST V2 API it is not possible to delete tasks. Looks like this intentional by the company to preserve your data for commercial reasons?

@brunorosilva
Copy link

brunorosilva commented Aug 23, 2023

Hi @haegar33 ,

The problem is not that you're unable to delete tasks. The problem is that the API does not check if the task exists before deleting it. Here's a code sample to demonstrate this behavior.

from mysecret import secret
from todoist_api_python.api import TodoistAPI
import numpy as np

api = TodoistAPI(secret)

try:
    is_success = api.delete_task(task_id=str(np.random.randint(1e2, 1e8))) # some fake id
    print(is_success)
except Exception as error:
    print(error)
> poetry run python3 test_api.py
True

I did not develop the API therefore I do not know if this is the intended behavior of the API, but it is easily fixable and, in my opinion, the SDKs should check if the task exists before deleting it.

I've managed to delete tasks using both the Python SDK and the REST v2 endpoint directly, so this is not the problem.

Using the REST v2 API w/ postman

image image

The response is 204 and the task was indeed deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants