taskwarrior icon indicating copy to clipboard operation
taskwarrior copied to clipboard

Filtering doesn't work when one of the words is "log"

Open Petemir opened this issue 3 years ago • 9 comments

To report a bug...

  • What command(s) did you run? task "rc.json.array=on" "rc.report.next.filter=daily log" "export" "next"

  • What did you expect to happen? Show me a list of tasks that have the string "daily log" on them

  • What actually happened? I got the following error: Mismatched parentheses in expression. If rc.report.next.filter=log, i.e. only the "log" word, the error is: "The expression could not be evaluated."

  • Paste the output of the task diag command.

task 2.6.1
   Platform: Linux

Compiler
    Version: 11.2.0
       Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
 Compliance: C++17

Build Features
      CMake: 3.18.4
    libuuid: libuuid + uuid_unparse_lower
  libgnutls: 3.7.1
 Build type: release

Configuration
       File: /home/petemir/.taskrc (found), 2417 bytes, mode 100664
       Data: /home/petemir/.task (found), dir, mode 40755
    Locking: Enabled
         GC: Enabled
    $VISUAL: vim
     Server: inthe.am:53589
         CA: /home/petemir/Projects/automation/computer/twarrior/inthe.am/ca.cert.pem, readable, 2405 bytes
Certificate: /home/petemir/Projects/automation/computer/twarrior/inthe.am/private.certificate.pem, readable, 2710 bytes
        Key: /home/petemir/Projects/automation/computer/twarrior/inthe.am/private.key.pem, readable, 17764 bytes
      Trust: ignore hostname
    Ciphers: NORMAL
      Creds: inthe_am/matiaslaporte/************************************

Hooks
     System: Enabled
   Location: /home/petemir/.task/hooks
     Active: on-modify.timewarrior (executable)
   Inactive: 

Tests
   Terminal: 322x33
       Dups: Scanned 591 tasks for duplicate UUIDs:
             No duplicates found
 Broken ref: Scanned 591 tasks for broken references:
             No broken references found

Petemir avatar Dec 01 '21 14:12 Petemir

with verbose, it's doing like this:

Filter: ( daily
Mismatched parentheses in expression

however if using rc.report.next.filter="'daily log'" (note extra quotes), it doesn't fail:

Configuration override rc.report.next.filter='daily log'
Filter: ( 'daily log' )

however it's looking for those single quotes actually in the matched text, so that's probably not what you want. Note that using different words, such as rc.report.next.filter="files point" it becomes clear it's splitting them into separate clauses on whitespace:

Configuration override rc.report.next.filter=files point
Filter: ( description ~ files and description ~ point )

so, I don't think it will work for your intended query even if log wasn't problematic. Don't know what correct/intended behavior is, just adding some data points

smemsh avatar Dec 02 '21 00:12 smemsh

Hi, thanks for your answer. Command syntaxis comes from using @kdheepak 's taskwarrior-tui. If there's something not working there I'll let him know, but for other queries (without log) it seems to work. Thanks!

Petemir avatar Dec 02 '21 08:12 Petemir

I’m surprised it is doing "rc.report.next.filter=daily log" instead of "rc.report.next.filter='daily log'". I’ll look into that on taskwarrior-tui. That could be the problem.

Thanks for pinging me here.

kdheepak avatar Dec 02 '21 15:12 kdheepak

I think it is sill a problem in Taskwarrior, because:

(1) "log" shouldn't be special... even if you just use "log" alone without a space, the same issue appears:

 $ task rc.verbose=on rc.report.next.filter=log export next
Configuration override rc.verbose=on
Configuration override rc.report.next.filter=log
Filter: (
The expression could not be evaluated.

(2) the inability to provide any space at all (without the query breaking into two separate clauses that get ANDed), means no literal string with a space can ever be searched for. Unless there is some other syntax to quote it (entirely possible)

smemsh avatar Dec 06 '21 16:12 smemsh

@Petemir I think this is possible to fix on taskwarrior-tui side. I made a PR for it, would you be able to test it?

kdheepak avatar Dec 06 '21 18:12 kdheepak

@kdheepak If I understand your patch, it adds single quotes to the argument vector, ie rc.report.foo.filter='bar' but that will just search for quotes in the matched text, as mentioned above. For example, I have many tasks with the letter t in them, but this query with additional single quotes will return an empty set:

 $ task rc.verbose=on "rc.report.next.filter='t'" export next
[
]
Configuration override rc.verbose=on
Configuration override rc.report.next.filter='t'
Filter: ( 't' )

it also can't fix taskwarrior's apparent special treatment of the word "log"

smemsh avatar Dec 06 '21 22:12 smemsh

If I understand your patch, it adds single quotes to the argument vector, ie rc.report.foo.filter='bar' but that will just search for quotes in the matched text, as mentioned above.

You are right, thanks for catching that. I made another commit just now to remove the single quotes, this will run task rc.verbose=on "rc.report.next.filter=t" export next instead. Users want they can add single quotes manually in their filter string in the app if they want.

The log issue might still remain (I haven't been able to test that yet). I'll not make a new release for taskwarrior-tui till I get a chance to test everything properly.

kdheepak avatar Dec 06 '21 22:12 kdheepak

The log issue might still remain

For sure it's real (see above examples), but I don't believe it's something you can work around in your program that invokes taskwarrior. You would have to export all records with no filter and do your own search through the results to avoid it. The taskwarrior-tui stuff is orthogonal to the two real taskwarrior bugs that are apparent:

(1) cannot specify a match string with spaces (they get ANDed as separate clauses) (2) special treatment of the word "log" (and possibly other words) in query string

smemsh avatar Dec 07 '21 17:12 smemsh

fyi, I think that also the word "daily" has some kind of special treatment, as changing in the original query to rc.report.next.filter=daily shows no results, but if I have rc.report.next.filter=Write daily more tasks are shown, although tasks that have only "Write", though, and not "daily" on them. The same happens with weekly, and I would suppose with yearly...

Petemir avatar Dec 10 '21 08:12 Petemir