Skip to content

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

Open
@lyndhurst

Description

@lyndhurst

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions