-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exit code to hook script seems to be ignored #3538
Comments
It looks like this should be implemented by throwing 0 (weird, but ok..): Lines 152 to 163 in d1a3573
And the Lines 76 to 79 in d1a3573
There's also a test for this behavior: taskwarrior/test/hooks.on-add.test.py Lines 78 to 94 in d1a3573
So I'm not sure what's wrong here. One thought is that maybe
is being read from the hook before it exits, and the add proceeds? I don't think it should do that, but commenting out that line should be a quick way to check. |
Sure I can give that a try. Report back in a few mins with results. Before I updated the code, it would exit with the Python exception. Arguably because the exception was not handled gracefully and the hook was not providing the feedback message back to Taskwarrior, Taskwarrior was ignoring the exit status? But in this state the task would still be added to the database. Here is the full output from this morning when I decide to take a few moments to handle the exception. You can see at the very end Taskwarrior stating that it did not get a feedback message.
It also occurs to me that there are other hook scripts and that may be a factor. Here is a list of the hook scripts so that you have a more complete picture of the environment. ❯ ls -l ~/.task/hooks
total 80
drwxr-xr-x 3 hickey HQ\Domain Users 96 Jul 5 10:02 __pycache__
-rwxr-xr-x@ 1 hickey HQ\Domain Users 5255 Jul 5 10:00 kanboard_functions.py
lrwxr-xr-x@ 1 hickey HQ\Domain Users 24 Apr 26 22:32 on-add.blocks_attr.py -> on-modify.blocks_attr.py
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2594 Jul 5 10:30 on-add.kanboard.py
---------- 1 hickey HQ\Domain Users 52 Apr 26 22:32 on-add.sync
---------- 1 hickey HQ\Domain Users 93 Apr 26 22:32 on-exit.sync
lrwxr-xr-x@ 1 hickey HQ\Domain Users 24 Apr 26 22:32 on-launch.blocks_attr.py -> on-modify.blocks_attr.py
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2662 Apr 26 22:32 on-modify.blocks_attr.py
-rwxr-xr-x@ 1 hickey HQ\Domain Users 6673 Apr 26 22:32 on-modify.kanboard.py
---------- 1 hickey HQ\Domain Users 52 Apr 26 22:32 on-modify.sync
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2198 Apr 26 22:32 on-modify.timewarrior I can not tell you at this point if |
I am sorry to say that even removing the JSON of the task from ❯ task add foobar
Context 'work' set. Use 'task context none' to remove.
Vault is sealed, on post https://moab.wt0f.com:8200/v1/auth/userpass/login/hickey
❯ task
ID Age Project Description Urg
1 8w GitLab Remove extreneous values from helm values file 2.11
2 7w Create ticket to turn on GL Pages 1.08
3 55min Document adding GitLab SOS to Confluence 0.8
4 52min Create Nexus proxy to pull from registry.gitlab.com 0.8
5 52min Create Nexus proxy to pull from ghcr.io 0.8
6 5s foobar 0.8
6 tasks
Context 'work' set. Use 'task context none' to remove. I will also tell you that before submitting the bug report, I tried to change the task Also, in the exit-status section of the hooks documentation the following statement is found.
Does this not tend to indicate that the task should be emitted whether there is a failure or not? |
It does indicate that, but I thought perhaps that was the bug. I guess not! |
Also, on a hunch I just disabled the ❯ ls -l
total 80
drwxr-xr-x 3 hickey HQ\Domain Users 96 Jul 5 10:02 __pycache__
-rwxr-xr-x@ 1 hickey HQ\Domain Users 5255 Jul 5 10:00 kanboard_functions.py
lrwxr-xr-x@ 1 hickey HQ\Domain Users 24 Apr 26 22:32 on-add.blocks_attr.py -> on-modify.blocks_attr.py
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2596 Jul 5 12:21 on-add.kanboard.py
---------- 1 hickey HQ\Domain Users 52 Apr 26 22:32 on-add.sync
---------- 1 hickey HQ\Domain Users 93 Apr 26 22:32 on-exit.sync
lrwxr-xr-x@ 1 hickey HQ\Domain Users 24 Apr 26 22:32 on-launch.blocks_attr.py -> on-modify.blocks_attr.py
---------- 1 hickey HQ\Domain Users 2662 Apr 26 22:32 on-modify.blocks_attr.py
-rwxr-xr-x@ 1 hickey HQ\Domain Users 6673 Apr 26 22:32 on-modify.kanboard.py
---------- 1 hickey HQ\Domain Users 52 Apr 26 22:32 on-modify.sync
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2198 Apr 26 22:32 on-modify.timewarrior
❯
❯
❯
❯ task add foobar2
Context 'work' set. Use 'task context none' to remove.
Vault is sealed, on post https://moab.wt0f.com:8200/v1/auth/userpass/login/hickey
❯ task
ID Age Project Description Urg
1 8w GitLab Remove extreneous values from helm values file 2.11
2 7w Create ticket to turn on GL Pages 1.08
3 1h Document adding GitLab SOS to Confluence 0.8
4 1h Create Nexus proxy to pull from registry.gitlab.com 0.8
5 1h Create Nexus proxy to pull from ghcr.io 0.8
6 8min foobar 0.8
7 5s foobar2 0.8
7 tasks
Context 'work' set. Use 'task context none' to remove. |
Just to check, is the script really exiting with a nonzero status? It's hard to see how this could differ from taskwarrior/test/test_hooks/on-add-reject Lines 1 to 19 in d1a3573
|
Added the script as ❯ ls -l
total 88
drwxr-xr-x 3 hickey HQ\Domain Users 96 Jul 5 10:02 __pycache__
-rwxr-xr-x@ 1 hickey HQ\Domain Users 5255 Jul 5 10:00 kanboard_functions.py
lrwxr-xr-x@ 1 hickey HQ\Domain Users 24 Apr 26 22:32 on-add.blocks_attr.py -> on-modify.blocks_attr.py
-rw-r--r-- 1 hickey HQ\Domain Users 453 Jul 5 12:40 on-add.force-exit.sh
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2596 Jul 5 12:21 on-add.kanboard.py
---------- 1 hickey HQ\Domain Users 52 Apr 26 22:32 on-add.sync
---------- 1 hickey HQ\Domain Users 93 Apr 26 22:32 on-exit.sync
lrwxr-xr-x@ 1 hickey HQ\Domain Users 24 Apr 26 22:32 on-launch.blocks_attr.py -> on-modify.blocks_attr.py
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2662 Apr 26 22:32 on-modify.blocks_attr.py
-rwxr-xr-x@ 1 hickey HQ\Domain Users 6673 Apr 26 22:32 on-modify.kanboard.py
---------- 1 hickey HQ\Domain Users 52 Apr 26 22:32 on-modify.sync
-rwxr-xr-x@ 1 hickey HQ\Domain Users 2198 Apr 26 22:32 on-modify.timewarrior
❯ chmod 755 on-add.force-exit.sh
❯
❯
❯ task add foobar3
Context 'work' set. Use 'task context none' to remove.
FEEDBACK
❯ task
ID Age Project Description Urg
1 8w GitLab Remove extreneous values from helm values file 2.11
2 7w Create ticket to turn on GL Pages 1.08
3 1h Document adding GitLab SOS to Confluence 0.8
4 1h Create Nexus proxy to pull from registry.gitlab.com 0.8
5 1h Create Nexus proxy to pull from ghcr.io 0.8
6 16min foobar 0.8
7 8min foobar2 0.8
8 6s foobar3 0.8
8 tasks
Context 'work' set. Use 'task context none' to remove. |
I'm stumped! Locally, with a copy of the reject hook quoted above installed:
I suppose the context is different -- I don't really know how contexts work -- but that seems unrelated. |
I am with you also. Completed stumped. I just verified that I am also getting an exit code of I will keep looking at this and see if I can make any headway as to what is going on. Is there any debug output that can be enabled to see what |
You can try |
@hickey In order to debug this, you can also use
|
To report a bug...
A bit of context around this bug report.
I have a hook script that has been developed to add or modify the task on a Kanban board. In order to do so the hook script interacts with Vault to retrieve the token to interact with the Kanban API.
Everything works fine except that once in a while the Vault database is sealed and needs to be unsealed. Previously I would see a Python exception and just know that Vault was sealed. I was just doing a bit of work to handle the situation a little more gracefully.
Here is the bit of Python code that I just updated by adding the exception handling.
task add TASK_TO_BE_ADDED
In the condition that Vault is sealed , I would expect that the task be dropped and not added to the Taskwarrior database.
Consulting the documentation for the Taskwarrior hooks at https://taskwarrior.org/docs/hooks/#exit-status, it seems to indicate that if a hook exists with a non-zero exit status that the task would be discarded.
As can be seen in the output above, I capture the exception and Taskwarrior is processing the exception message as a feedback message. The hook then exits with a exit code of 2 which should signal that the task is to be discarded. That does not seem to be happening as you can see in the following output.
task diag
command.The text was updated successfully, but these errors were encountered: