-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Behavior change in handling \
at the very end of tasks
queries [in Live Preview, due to Obsidian unintended change]
#3137
Comments
Hi Blake, Thanks for using Tasks. Cannot reproduce the problemWith the exactly query you gave, I cannot reproduce the problem. The change in behaviour
I maintain a special page for that situation: https://publish.obsidian.md/tasks/What+is+New/Breaking+Changes By coincidence, the feature that changed that behaviour celebrated its first birthday today!
Reading that section of the docs will enable you to update your searches to get the original behaviour |
I’ll assume that no news is good news, and close this |
Sorry I've been out of town the past week. After revisiting my minimal reproducible example, I've found that the buggy behavior I describe is only happening in the Live Preview mode, but not in the Reading Mode. Here we see that Reading Mode is correct, even with the trailing slash. See the screenshot below (with hasty red PowerPoint annotations are mine) where I present three views of the same note. So query parsing in Live Preview mode somehow differs from Reading Mode for the same source query! Here's a zipped up test vault showing this behavior, produced from my Windows machine just now. Thanks for the pointer to use |
Thanks for replying. I've re-opened the ticket. Why I encouraged you to use the
|
And the difference in behaviour between Live Preview and Reading mode is an Obsidian bug, and outside of Tasks' control. |
Thanks for the detailed reply! I think the primary thing worth communicating here, perhaps in an appendix/callout/admonition added to https://publish.obsidian.md/tasks/Queries/Line+Continuations, is that this behavior change has emerged recently (probably in the stable release of Obsidian 1.7.4 this month) and can manifest as very slow queries all over the vault trying to collect all tasks in the vault. I've drafted a quick PR (#3163) adding such a mention to the line continuations docs, if you deem it reasonable to communicate that. I think perhaps the stable/public release of Obsidian 1.7.4 is the culprit, which includes the Catalyst/preview changes from Obsidian 1.7.2, judging by the changelog entry I haven't verified this by installing different isolated versions of Obsidian and seeing when the behavior emerges, but I do believe it to be a recent behavior change since it wasn't happening to me until recently. Probably my language was imprecise when mentioning the |
…continuations See obsidian-tasks-group#3137. From that discussion, added an appendix entry to this indicating the Live Preview behavior change since Obsidian 1.7.2 that leads to malformed queries *only in Live Preview mode*. This upstream Obsidian bug affects Obsidian Tasks code blocks and can manifest as surprisingly slow queries running to return all tasks in the vault. The culprit may be [Obsidian 1.7.2](https://obsidian.md/changelog/2024-09-19-desktop-v1.7.2/), judging by the changelog entry `Live preview now only escapes special characters (not letters and numbers).`. See [my comment](obsidian-tasks-group#3137 (comment)) and [this comment](obsidian-tasks-group#3137 (comment)) for more detail. - [ ] Before merging this documentation change, verify that Obsidian v1.7.2 really is the culprit here
Someone today shared the link to the Forum report of the extra new line: Blake, the thing I am missing in all of this is why you had query ending with a trailing slash at the end of a Edit: or at the end of a boolean expression like that? What purpose were you expecting it serve? I would also want to know whether you previously using a pre-Tasks-7.0.0 release? Thanks for the PR. I don't know enough yet to make a decision on what to do, if anything, with this ticket - it will impart include understanding the curious |
Note: I've made some edits to the comment above... |
EDIT: See my follow-up comment below, which may make the rest of this long-winded comment moot. If only I was out of town for another week maybe I wouldn't have caused us both to spend time chasing a problem that will be fixed soon anyways 😅. Some of my queries for "dashboard"-like overview documents use boolean combinations, use only parentheses as a delimiter, don't use quotes, and use line continuations for readability/refactorability in complex logic. When refactoring queries like in the example I give below, sometimes the final line ends up moving, not being the final line anymore, so keeping the trailing slash there makes it consistent and easy to move without breaking the query. Not being able to include a final trailing slash creates a usability annoyance similar to how the lack of a trailing comma in a final JSON element means it will break if you move that element without adding a comma to it. I'm pretty sure I have been using at least 7.0 at for the past six months, but I wrote queries like the example below during v6 and haven't modified them much. And I think we've found that my recent update from ~7.0 to the latest Tasks is not the root cause of the behavior change, rather it's probably the latest version of Obsidian changing Live Preview (will need to be confirmed before decision on the PR). Maybe the upstream bug be fixed quickly in Obsidian proper and this issue topic is all that's needed to signpost the danger to other users of Obsidian Tasks. In any case, it's fine to decline the docs contribution if this topic suffices to document it! More detailDetailsI guess the minimum example doesn't really illustrate the "why" of wanting a final trailing slash at all. So below is an example of the kinds of "dashboard"-like tasks documents I use to monitor tasks of a given kind throughout a vault. While the tasks queries below include a lot of boilerplate/repetition, they're fairly easy to manage with a little automation. Use of the explicit ANDs and ORs, and splitting queries across lines make it much easier for one query to exclude results already handled by another query by reuse and negation of a given "sub-query". Until the recent behavior change of a trailing slash in a given code block breaking Live Preview query parsing, all of my more "complex" queries like this had final trailing slashes like I know that the "philosophy" of the tasks plugin is to instead set up sorting/filtering rules within one master query, and use task priorities and such to simplify queries, avoiding a lot of the "boilerplate" you see below. But I just wasn't able to craft the queries I felt I needed using simple query language. Possibly the example below is a "tasks smell", and just is the "wrong" way to go about task dashboarding, but I think the "final trailing slash" issue may crop up even in simpler queries. Anyways, I've scrubbed my vault of all final trailing slashes to sidestep the current Live Preview issue. It's not really a big deal, but I imagine that anyone making heavy use of line continuations and boolean combinations to craft queries might be bit by the final trailing slash bug and end up with a query that vomits all the tasks in the vault in Live Preview mode, resulting in Obsidian stalling/hanging. Contents of
|
A recent comment suggests they're working on fixing it in 1.7.5, so perhaps the documentation PR might cause some unnecessary churn! My initial concern was whether or not this would be fixed upstream promptly and cause noise in Obsidian Tasks in the meantime. Anyways, thanks for your help in identifying the root cause while showing me some new tasks tricks along the way! Feel free to re-close this issue and/or the PR as you see fit. |
Thanks for both your messages, which I will reply to in full when I have some time. I am actually intending to make Tasks adjust the query input to prevent the problem case from happening. As well as working around the current Obsidian issue, this issue has shown it will be necessary to be done in advance of #2459, to prevent confusing behaviours if users pass in queries like that currently created in Live Preview... |
\
at the very end of tasks
queries\
at the very end of tasks
queries [in Live Preview, due to Obsidian bug]
\
at the very end of tasks
queries [in Live Preview, due to Obsidian bug]\
at the very end of tasks
queries [in Live Preview, due to Obsidian unintended change]
My initial plan was simply to make the However, upon investigation, the logic error is in here: obsidian-tasks/src/Query/Scanner.ts Lines 82 to 97 in e1a8a1c
If:
Then:
The simplest fix is probably to adjust the if (!continuePreviousLine || weAreOnTheLastLineOfTheFile) { |
I've edited the reproduction steps in the first post above to add the critical information that it needs to be viewed in Live Preview, and it likely matters that Obsidian 1.7.4 is used... |
…n-last-line fix: '\' at end of last line in query no longer discards the instruction Fixes #3137
@blakeNaccarato Many thanks for discovering and logging this. I have fixed the underlying cause in the Tasks code in PR #3166. For all the hours spent on understanding and discussing the problem, it turned out there was simple (and acceptable) workaround in code to prevent the problem. I will release this when I have time - perhaps later today. And I do still plan to reply to some of the discussion above, where I feel clarification is worthwhile. |
Released in 7.12.3 |
Great! Glad I could help! |
Please check that this issue hasn't been reported before.
Steps to reproduce
I recently updated Obsidian Tasks after few months of not updating, and lots of my queries have started returning nearly every task in my vault. Queries which had a final
\
, e.g. in the "leaky" query below, would slow down Obsidian significantly and list all tasks in the vault. (The reason I often have trailing\
in queries is that I tend to mix/match query snippets and keeping the trailing\
is robust to changes in that query, e.g. moving that "clause" up or down, or elsewhere).I found that removing the
\
at the very end of the query restored functionality to what I expected from before updating, properly filtering tasks.I would say tentatively that this apparent "regression" has cropped up in one of the updates in the past ~six months. If there's an easy methodology for me to quickly "bisect" Tasks plugin versions to narrow down the exact release this happened on, or Obsidian Sync logs I'm unaware of, please let me know. My Sync history only shows in the manifest my recent update to 7.10.2, then updating to 7.11.1, so I can't exactly recall which version I updated from when this regression crept in.
Simple reproduction
one.md
andtwo.md
with the following contentstwo.md
. The only difference is the trailing slash. The leaky query "incorrectly" sees the task inone.md
.one.md
two.md
Expected Behavior
Queries with trailing
\
should still function properly.Current behaviour
Queries with trailing
\
fetch everything in the vault instead of filtering as expected.Which Operating Systems are you using?
Obsidian Version
1.7.4
Tasks Plugin Version
7.11.1
Checks
Possible solution
The text was updated successfully, but these errors were encountered: