taskwarrior: Cannot add dependency to a task by using short UUID of the blocking task

To report a bug…

  • What command(s) did you run?
$ task a3b2d753 modify depends:ab52a631
  • What did you expect to happen?
Modifying task a3b2d753 'Submit report'.
Modified 1 task.
Project 'work.assignment004' is 0% complete (2 of 2 tasks remaining).

or (because task a3b2d753 currently has ID 217):

Modifying task 217 'Submit report'.
Modified 1 task.
Project 'work.assignment004' is 0% complete (2 of 2 tasks remaining).
  • What actually happened?
Could not create a dependency on task 0 - not found.
  • Paste the output of the task diag command.
task 2.5.1
   Platform: Linux

Compiler
    Version: 6.3.0 20170516
       Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
 Compliance: C++11

Build Features
      Built: Nov 28 2018 20:17:42
     Commit: 493bbadb1
      CMake: 3.7.2
    libuuid: libuuid + uuid_unparse_lower
  libgnutls: n/a
 Build type: 

Configuration
       File: /home/sampablokuper/.taskrc (found), 4524 bytes, mode 100644
       Data: /home/sampablokuper/.task (found), dir, mode 40755
    Locking: Enabled
         GC: Enabled
     Server: 
      Trust: strict
Certificate: , not readable, 0 bytes
        Key: , not readable, 0 bytes
    Ciphers: NORMAL
      Creds: 

Hooks
     System: Enabled
   Location: /home/sampablokuper/.task/hooks
             (-none-)

Tests
      $TERM: xterm-256color (251x54)
       Dups: Scanned 1207 tasks for duplicate UUIDs:
             No duplicates found
 Broken ref: Scanned 1207 tasks for broken references:
             No broken references found

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (13 by maintainers)

Most upvoted comments

I agree. I actually touched this code recently, perhaps we can get this into 2.6.2.

I vote for this.

@ddeimeke wrote:

I do not think this is an issue. The UUID is guarenteed to work and the UUID is unique as whole, not as part.

It is an issue. Full UUIDs are too long to be feasible in reports on typical terminals; IDs change and this is a barrier to usability (for some people, at least) and to scripting. Short UUIDs, like abbrev hashes in Git (aka “short SHA-1 hashes”), are the happy medium. So, short UUIDs should work wherever IDs and UUIDs do.

Git is smart enough to figure out what commit you’re referring to if you provide the first few characters of the SHA-1 hash, as long as that partial hash is at least four characters long and unambiguous; that is, no other object in the object database can have a hash that begins with the same prefix. (Source)

I don’t know how Git handles hash collisions, but I believe its collision handling was improved in the wake of SHAttered. TaskWarrior could handle potential collisions something like this:

  • Given a hexadecimal reference, check all UIDs for matching heads; and
  • If the reference is also a valid integer, then also check all IDs for full matches.
  • Then, if the number of matches is 0, print an error that no matching task was found;
  • else if the number of matches is 1, then use that referent;
  • else print an error along the lines Ambiguous reference: 12345678. Did you mean task ID 12345678 'Buy groceries', or did you mean task UUID 12345678-6d26-4d38-bbb8-7bee275834c7 'Telephone grandma'?

One technique Git uses to reduce the likelihood of collisions is to set a minimum length for short hashes. TaskWarrior already seems to use a minimum of 8 characters for short UUIDs, which is probably sufficient for most users.