strawpants / kanboard_taskwarrior

Sync tasks between taskwarrior and kanboard
MIT License
2 stars 0 forks source link

First setup: KeyError: 'uda.swimlane.values' #2

Open justyns opened 10 months ago

justyns commented 10 months ago

I ran into #1 as well, but after putting in my username to get passed that, I also ran into this error:

> tasksync.py -v -c homelab
Project mapping homelab does not exist yet, create a new mapping (y/n)? [y]:
tasksync-INFO:Setting up Kanboard- taskwarrior mapping
Enter Kanboard serveraddress: https://kanboard.my.domain
Enter your Kanboard username: justyns
Enter personal Kanboard API Token (create in Kanboard under My profile -> API): xxx
Enter assignee whos task need to be synced (leave empty for getting all tasks): justyns
Whether to apply 'task sync' (sync with taskd server) before doing the syncing operation (y/n) [n]:
Select Taskwarrior alias for Kanboard swimlane Default swimlane [Default swimlane]:
Select Taskwarrior option for Kanboard Column Backlog,(0:WAITING, 1:ACTIVE, 2:WEEK, 3:TOMORROW, 4:COMPLETED, -1:Do not set) [0]:
Select Taskwarrior option for Kanboard Column Next,(1:ACTIVE, 2:WEEK, 3:TOMORROW, 4:COMPLETED, -1:Do not set) [1]: 2
Select Taskwarrior option for Kanboard Column Doing,(1:ACTIVE, 3:TOMORROW, 4:COMPLETED, -1:Do not set) [1]:
Select Taskwarrior option for Kanboard Column Done,(3:TOMORROW, 4:COMPLETED, -1:Do not set) [3]: 4
Traceback (most recent call last):
  File "/home/justyns/.pyenv/versions/3.11.2/bin/tasksync.py", line 111, in <module>
    main(sys.argv)
  File "/home/justyns/.pyenv/versions/3.11.2/bin/tasksync.py", line 86, in main
    conn.config(args.project)
  File "/home/justyns/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kanboard_taskwarrior/db.py", line 192, in config
    configUDA(config["mapping"])
  File "/home/justyns/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kanboard_taskwarrior/config.py", line 49, in configUDA
    udaval.extend(tw.config[valky].split(","))
                  ~~~~~~~~~^^^^^^^
  File "/home/justyns/.pyenv/versions/3.11.2/lib/python3.11/site-packages/tasklib/task.py", line 32, in __getitem__
    return copy.deepcopy(self.viewed_dict.__getitem__(key))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'uda.swimlane.values'

Python deps:

Kanboard and php version:

Application version: v1.2.33
PHP version: 8.2.10 
strawpants commented 9 months ago

Thanks for reporting. It seems quite a logical error when first setting up a mapping. I didn't run yet in this error, because my setup has grown 'organically' and the swimlanes uda was apparently already present in my taskwarrior setup when I added this code.

I've made a quick fix (hopefully) in this branch. Hopefully it solves your problem.

Just for context: although I use kanboard_taskwarrior on a daily basis, it still has some quirks. I didn't robustly tested it on pristine setups, and I can also imagine some project setups may cause unexpected mapping problems.

justyns commented 9 months ago

Hey, thanks for the quick fix! I can confirm that branch fixes the KeyError I ran into.

Are there any other initial setup steps that might be missing from the docs? I got a new error about the board not existing. I'll probably try to look through the code this weekend to see if I'm missing something obvious

Just for context: although I use kanboard_taskwarrior on a daily basis, it still has some quirks. I didn't robustly tested it on pristine setups, and I can also imagine some project setups may cause unexpected mapping problems.

No worries! I'm not planning on using it for anything critical, just some personal and homelab stuff. Sometimes I like having a kanban view, but I also like taskwarrior.

justyns commented 9 months ago

@strawpants an update

I got this error when trying to add a new connection:

Traceback (most recent call last):
  File "/home/justyns/.pyenv/versions/3.11.2/bin/tasksync.py", line 111, in <module>
    main(sys.argv)
  File "/home/justyns/.pyenv/versions/3.11.2/bin/tasksync.py", line 86, in main
    conn.config(args.project)
  File "/home/justyns/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kanboard_taskwarrior/db.py", line 199, in config
    cur.execute(f"INSERT INTO {kbserverTable} (url,user,apitoken,project,projid,lastsync,mapping,runtaskdsync) VALUES (?,?,?,?,?,?,?,?)",values)
sqlite3.OperationalError: table kbserver has no column named runtaskdsync

For some reason, the runtaskdsync column didn't exist yet. I saw there is a migration for it in db.py, but I guess it didn't run? I ended up just manually adding the column and it was fine after that.

Once I got the connection added, I ran into this error:

tasksync-DEBUG:Creating new Taskwarrior task from Kanboard task 205
Traceback (most recent call last):
  File "/home/justyns/.pyenv/versions/3.11.2/bin/tasksync.py", line 111, in <module>
    main(sys.argv)
  File "/home/justyns/.pyenv/versions/3.11.2/bin/tasksync.py", line 107, in main
    conn.syncTasks(args.project)
  File "/home/justyns/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kanboard_taskwarrior/db.py", line 284, in syncTasks
    self.syncSingle(entry)
  File "/home/justyns/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kanboard_taskwarrior/db.py", line 420, in syncSingle
    uuid,twtask=twFromkbTask(kbtask,projconf=projconf,twtask=twtask,twclient=twclnt,test=self._test)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/justyns/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kanboard_taskwarrior/taskmap.py", line 36, in twFromkbTask
    datedue=int(kbtask['date_due'])
            ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

I changed taskmap.py line 36 to be datedue=int(kbtask['date_due'] or 0). kbtask['date_due'] was None for me, probably because I don't really use due dates in kanboard very often.

And I'm happy to say syncing both ways seems to be working correctly now :)