GothenburgBitFactory / taskwarrior

Taskwarrior - Command line Task Management
https://taskwarrior.org
MIT License
4.5k stars 311 forks source link

on-add hooks are ignored #3653

Closed blaisegarant closed 2 weeks ago

blaisegarant commented 1 month ago

To report a bug...

I obfuscated some results

Timer Config::load (/home/bgarant/.taskrc) 0.000892 sec
Applying context 'inbox'
Detected context string: +inbox
Found misnamed hook script /home/bgarant/.task/hooks/__init__.py
Found misnamed hook script /home/bgarant/.task/hooks/*****
Found misnamed hook script /home/bgarant/.task/hooks/****
Found hook script /home/bgarant/.task/hooks/on-add.testme.py
Found hook script /home/bgarant/.task/hooks/on-modify.timewarrior
Found misnamed hook script /home/bgarant/.task/hooks/utils.py
Parse Tree (before command-specifіc processing)
  _original_args
    task rc.debug=1 add +inbox Tata rc.debug.hooks=2
  _args
    word basename='task' raw='task' BINARY 
    pair modifier='debug' name='rc' raw='rc.debug=1' separator='=' value='1' CONFIG ORIGINAL 
    identifier canonical='add' raw='add' ORIGINAL CMD USESCONTEXT ALLOWSMODIFICATIONS 
    tag name='inbox' raw='+inbox' sign='+' MODIFICATION 
    identifier raw='Tata' ORIGINAL MODIFICATION 
    pair modifier='debug.hooks' name='rc' raw='rc.debug.hooks=2' separator='=' value='2' CONFIG ORIGINAL 

  MODIFICATION tags <-- add 'inbox'
  MODIFICATION description <-- 'Tata'
Hook: Calling /home/bgarant/.task/hooks/on-add.testme.py
Hook: input
  {"description":"Tata","entry":"20241015T201220Z","modified":"20241015T201220Z","status":"pending","uuid":"9d5fa7bb-7e79-4d87-9f63-9a0b86bbda59","tags":["inbox"]}
Hooks: args
  api:2
  args:task rc.debug=1 add +inbox Tata rc.debug.hooks=2
  command:add
  rc:/home/bgarant/.taskrc
  data:/home/bgarant/.task
  version:3.0.2
Timer Hooks::execute (/home/bgarant/.task/hooks/on-add.testme.py) 0.042236 sec
Hook: output
  {"description":"Titi","entry":"20241015T201220Z","modified":"20241015T201220Z","status":"pending","uuid":"9d5fa7bb-7e79-4d87-9f63-9a0b86bbda59","tags":["inbox"]}
Hook: Completed with status 0

Perf task 3.0.2 - 20241015T201220Z init:4055 load:0 gc:0 filter:0 commit:0 sort:0 render:0 hooks:42461 other:126829 total:173345

According to this, my hook should have worked. But it's not the case

❯ task list

ID Age   Tags  Description Urg 
68 10min inbox Tata         0.8

Here are the hook and a small dependency from my utils.py

on-add.testme.py

#!/usr/bin/env python
from utils import load_input
import sys
import json

new_task = load_input()
new_task["description"] = new_task["description"].replace("a", "i")
print(json.dumps(new_task, separators=(",", ":")))

sys.exit(0)

where

def load_input():
    while True:
        nextline = sys.stdin.readline()
        if nextline.startswith('{'):
            break
    return json.loads(nextline)

Note separators is there because I tried to have the same format as the input to no avail

task 3.0.2 Platform: Linux

Compiler Version: 13.2.1 20240206 [revision 67ac78caf31f7cb3202177e6428a46d829b70f23] Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64 Compliance: C++17

Build Features CMake: 3.29.2 libuuid: libuuid + uuid_unparse_lower Build type: RelWithDebInfo

Configuration File: /home/bgarant/.taskrc (found), 5368 bytes, mode 100644 Data: /home/bgarant/.task (found), dir, mode 40755 Locking: Enabled GC: Enabled $EDITOR: vim Hooks System: Enabled Location: /home/bgarant/.task/hooks Active: on-add.testme.py (executable) Inactive: init.py (not executable)unrecognized hook name (not executable)unrecognized hook name (not executable)unrecognized hook name on-modify.timewarrior (not executable) utils.py (not executable)unrecognized hook name

Tests Terminal: 355x74 Dups: Scanned 1865 tasks for duplicate UUIDs: No duplicates found Broken ref: Scanned 1865 tasks for broken references: Task 38cabf8e-c132-426d-88b1-7aed0bb4b050 has nonexistent recurrence template 06af1267-8591-4287-a4ce-861b1c9657e1

felixschurk commented 1 month ago

Hei, before we look deeper into that. Could you maybe try it with the v3.1 release if the issue persists?

blaisegarant commented 1 month ago

Sorry, crazy week. It does work on 3.1 but I don't have access to the machine having the problem. I'll look monday but it should be good

blaisegarant commented 1 month ago

My other machine is on fedora and I can't make the 3.1 tarball work on it. Like I said, updating my archlinux's to 3.1 did the trick so I guess this could be close.

If you want me to test on fedora using 3.1 once rpm packages are availble, it'll be a my pleasure.

felixschurk commented 2 weeks ago

Yes, testing it on Fedora with the rpm should not harm.

I am also running Fedora, but compile it myself - so should also work with the rpm I assume.