todo-sync icon indicating copy to clipboard operation
todo-sync copied to clipboard

KeyError: 'id': Asana API changed from 'id' to 'gid'

Open pdblood opened this issue 4 years ago • 0 comments

@tmurph thanks for developing this tool. Are you still maintaining this repo? It looks like the Asana API changed so that expects 'gid' instead of 'id', so I hit this error when I try to use it:

$ todo-sync -v org ~/.emacs.d/init-todo-sync.el asana ASANA_TOKEN
Get From Source:
 (ts-init)

Send To Source:
 (ts-final)

Traceback (most recent call last):
  File "/home/pdblood/.local/bin/todo-sync", line 8, in <module>
    sys.exit(main())
  File "/home/pdblood/.local/lib/python3.8/site-packages/todo_sync/command_line.py", line 48, in main
    with module.ahead_source(
  File "/home/pdblood/.local/lib/python3.8/site-packages/todo_sync/mappers/org_to_asana.py", line 67, in ahead_source
    source = a.Source.from_client(client, verbose)
  File "/home/pdblood/.local/lib/python3.8/site-packages/todo_sync/backends/asana.py", line 298, in from_client
    c = cls(asana_client.users.me()['workspaces'][0]['id'],
KeyError: 'id'

If I change all the instances of 'id' to 'gid' in asana.py, it gets past this error, but then hits another one:

Send To Source:
 (ts-final)

Traceback (most recent call last):
  File "/home/pdblood/.local/bin/todo-sync", line 8, in <module>
    sys.exit(main())
  File "/home/pdblood/.local/lib/python3.8/site-packages/todo_sync/command_line.py", line 51, in main
    edit_script(b_source.get_tree(), a_source.get_tree(),
  File "/home/pdblood/.local/lib/python3.8/site-packages/todo_sync/backends/asana.py", line 403, in get_all_items
    node = self.make_task_node(task)
  File "/home/pdblood/.local/lib/python3.8/site-packages/todo_sync/backends/asana.py", line 328, in make_task_node
    return TaskNode.from_dict(
  File "/home/pdblood/.local/lib/python3.8/site-packages/todo_sync/node.py", line 17, in from_dict
    raise Exception('All Nodes must have an ID.'
Exception: All Nodes must have an ID.

{'id': None} is reserved for Root nodes.

I suspect it's a related issue, but in case I've broken something else with my quick attempt at fixing it, I figured I'd report it in case you're still interested in updating your code.

pdblood avatar Apr 26 '21 23:04 pdblood