GothenburgBitFactory / task-timewarrior-hook

MIT License
4 stars 0 forks source link

`on-modify.timewarrior` adds spurious tags #20

Closed dkasak closed 1 year ago

dkasak commented 1 year ago

The on-modify.timewarrior hook creates spurious tags:

❯ task add "Test task"
Created task 118.

❯ task 118 modify +foo +bar
Modifying task 118 'Test task'.
Modified 1 task.

❯ task 118 start
Starting task fb3270e0 'Test task'.
Started 1 task.
Note: '"Test task"' is a new tag.
Tracking , "Test task" a b f o r
  Started 2023-04-26T03:48:40
  Current                  40
  Total               0:00:00

Note the tags a, b, f, o, r.

This appears to happen because the JSON object passed to the hook sometimes contains a list for the tags, but other times it's a comma-separated list. Placing some print calls shows the hook sees this for the above task:

{
  "description": "Test task",
  "entry": "20230426T014808Z",
  "modified": "20230426T014829Z",
  "size": "small",
  "status": "pending",
  "uuid": "fb3270e0-06a5-4b3a-b272-59b2a1f32554",
  "tags": "bar,foo",
  "start": "20230426T014840Z"
}
dkasak commented 1 year ago

Modifying the task to add a baz tag shows the hook being called two times, once with a list and once with a comma-separated string:

✦ ❯ task 118 modify +baz
Modifying task 118 'Test task'.
Modified 1 task.
Removed Test task bar foo from @1
Note: '"Test task"' is a new tag.
Note: 'z' is a new tag.
Added Test task b a z , f o o , b a r to @1
{'description': 'Test task', 'entry': '20230426T014808Z', 'modified': '20230426T014840Z', 'size': 'small', 'start': '20230426T014840Z', 'status': 'pending', 'uuid': 'fb3270e0-06a5-4b3a-b272-59b2a1f32554', 'tags': ['bar', 'foo']}
{'description': 'Test task', 'entry': '20230426T014808Z', 'modified': '20230426T014840Z', 'size': 'small', 'start': '20230426T014840Z', 'status': 'pending', 'uuid': 'fb3270e0-06a5-4b3a-b272-59b2a1f32554', 'tags': 'baz,foo,bar'}

Presumably this could also be seen as a taskwarrior bug?

lauft commented 1 year ago

@dkasak Just a side note: The on-modify.timewarrior hook has its own repository 👉🏻 https://github.com/GothenburgBitFactory/task-timewarrior-hook. The issue will be transferred to there.

Presumably this could also be seen as a taskwarrior bug?

As far as I can see, the hooks expects tags to be an array of strings. So, if this is not the case, I agree that this looks like Taskwarrior doing something odd. Can you open an issue there?

Smith4545 commented 1 year ago

@dkasak If you use taskpirate or anything related to tasklib, take a look into this issue

https://github.com/tbabej/taskpirate/issues/19

dkasak commented 1 year ago

@Smith4545 Thank you for that reference. It's indeed what's causing my problem :( Which I think means we can close this issue.