Skip to content

Multiple ${query[[]]} expressions on the same page produce random (empty table) results #1938

@rc042

Description

@rc042

Version: SilverBullet v2

Description

When a page contains multiple ${query[[]]} expressions, some of them randomly render as (empty table) even though the same query works correctly when alone on the page.

The behavior is non-deterministic: on the same page, sometimes query 1 renders correctly and query 2 is empty, sometimes both render, sometimes both are empty.

Minimal reproducible example:

Page frontmatter:

---
week: 16
year: 2026
---

Test 1 — same alias t on both queries:

${query[[
  from t = index.tag("task")
  where not t.done
  and t.week == _CTX.currentPage.week
  and t.year == _CTX.currentPage.year
  and string.startsWith(t.page, "Journal/Projet/Alpha/2026/")
]]}

${query[[
  from t = index.tag("task")
  where not t.done
  and t.week == _CTX.currentPage.week
  and t.year == _CTX.currentPage.year
  and string.startsWith(t.page, "Journal/Projet/Alpha/2026/")
]]}

Result: Random — sometimes both display, sometimes one or both show (empty table).


Test 2 — distinct aliases t1 and t2:

${query[[
  from t1 = index.tag("task")
  where not t1.done
  and t1.week == _CTX.currentPage.week
  and t1.year == _CTX.currentPage.year
  and string.startsWith(t1.page, "Journal/Projet/Alpha/2026/")
]]}

${query[[
  from t2 = index.tag("task")
  where not t2.done
  and t2.week == _CTX.currentPage.week
  and t2.year == _CTX.currentPage.year
  and string.startsWith(t2.page, "Journal/Projet/Alpha/2026/")
]]}

Result: Same random behavior — distinct aliases do not fix the issue.


Test 3 — implicit _ variable (no alias):

${query[[
  from index.tag("task")
  where not _.done
  and _.week == _CTX.currentPage.week
  and _.year == _CTX.currentPage.year
  and string.startsWith(_.page, "Journal/Projet/Alpha/2026/")
]]}

${query[[
  from index.tag("task")
  where not _.done
  and _.week == _CTX.currentPage.week
  and _.year == _CTX.currentPage.year
  and string.startsWith(_.page, "Journal/Projet/Alpha/2026/")
]]}

Result: Same random behavior — using _ does not fix the issue either.


Any help is appreciated! 🙏 🙏 🙏

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