Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

item.sync() sends invalid data to servers #65

Open
ghost opened this issue Oct 29, 2019 · 0 comments
Open

item.sync() sends invalid data to servers #65

ghost opened this issue Oct 29, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2019

I'm not sure if this is an issue with the API itself or if I just have a wrong understanding, however, I found out that I can send invalid data to the server using api.sync() and that those data are accepted by the server and additionally saved and fetched on the next synchronisation.
To make it easier to understand I wrote a code snippet explaining what I mean:

api = todoist.TodoistAPI(token)
api.sync()

for item in api.state["items"]:
    if item["content"] == "test #issue65" and isinstance(item["due"], dict): # makes sure that we only modify an item that the content "test #issue65" and a due-date
        print(item["due"])
        item["due"] = ["i can put here", "whatever i want"]
        print(item["due"])
        api.sync()
        print(item["due"])

The result I get is the following:

{'date': '2019-10-29', 'timezone': None, 'is_recurring': False, 'string': 'Okt 29', 'lang': 'de'}
['i can put here', 'whatever i want']
['i can put here', 'whatever i want']

Creating a new Todoist-API-instance doesn't change anything:

def run_through():
    print("running through ...")
    token = "token"
    api = todoist.TodoistAPI(token)
    api.sync()
    for item in api.state["items"]:
        if item["content"] == "test #issue47":
            print(item["due"])
            if isinstance(item["due"], dict):  # makes sure that we only modify an item that the content "test #issue47" and a due-date
                item["due"] = ["i can put here", "whatever i want"]
                print(item["due"])
                api.sync()
                print(item["due"])

run_through()
run_through()

running through ...
{'date': '2019-10-29', 'timezone': None, 'is_recurring': False, 'string': '29 Okt', 'lang': 'de'}
['i can put here', 'whatever i want']
['i can put here', 'whatever i want']
running through ...
['i can put here', 'whatever i want']

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants