Skip to content
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

Error accessing original values from a on-modify hook #125

Open
lyndhurst opened this issue Oct 10, 2023 · 0 comments
Open

Error accessing original values from a on-modify hook #125

lyndhurst opened this issue Oct 10, 2023 · 0 comments

Comments

@lyndhurst
Copy link

lyndhurst commented Oct 10, 2023

Hi,
I have taskwarrior 2.6.2, and tasklib 2.5.1-2 installed with pacman.

Calling original values from a on-modify hook throws an error. Below are the steps to reproduce the error using a 'minimal' config generated by taskwarrior, and no other hooks than on-modify-tests.

#!/usr/bin/python3

import sys
from tasklib.task import Task

modified_task = Task.from_input()

old_tags = modified_task.original["tags"]

print(modified_task.export_data())
sys.exit(0)

Output:

❯ task 4 modify -test
Modifying task 4 'Some task'.
Traceback (most recent call last):
  File "/home/user/.config/task/tests/hooks/on-modify-tests", line 13, in <module>
    old_tags = modified_task.original["tags"]
               ~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tasklib/task.py", line 32, in __getitem__
    return copy.deepcopy(self.viewed_dict.__getitem__(key))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'tags'

task 4 does have a test tag originally, the same happens with t.original['description'] anyway.

Thanks in advance for your help.

@lyndhurst lyndhurst changed the title Many features not working from hooks Trying to access original values from a on-modify hook throws error Oct 11, 2023
@lyndhurst lyndhurst changed the title Trying to access original values from a on-modify hook throws error Error accessing original values from a on-modify hook Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant