CLI: tasks and tags silently return empty when called from terminal,


Category: Bug Reports
Tag: cli


Issue

Several CLI commands silently return empty or zero results when called from a terminal session. The commands succeed (exit code 0) but produce wrong output because they default to “active file” scope — which doesn’t exist in a CLI context.

This affects tasks, tags, and properties format=json.

Steps to reproduce

Tested in the Obsidian Sandbox vault (Help > Sandbox Vault) — no community plugins or themes enabled.

1. tasks returns empty even when tasks exist

The Sandbox vault contains 6 tasks:

> tasks all
- [x] #tags, [links](), **formatting** supported
- [x] list syntax required (any unordered or ordered list supported)
- [x] this is a complete item
- [?] this is also a complete item (works with every character)
- [ ] this is an incomplete item
- [ ] tasks can be clicked in Preview to be checked off

But without all:

> tasks total
0

> tasks todo
No tasks found.

Same in a 600+ note vault: tasks todo total → 0, tasks all todo total → 684.

2. tags returns empty even when tags exist

> tags counts total
0

> tags all counts total
1

Same in main vault: tags counts → “No tags found.”, tags all counts → 141 lines of data.

3. Error messages still return exit code 0

$ obsidian base:views
Error: Active file is not a base file: ...
$ echo $?
0

4. properties format=json returns YAML-like output instead of JSON

$ obsidian properties path=somefile.md format=json
# Output is YAML-like, not valid JSON

(Tested in main vault. Sandbox vault’s default files have no frontmatter.)

Did you follow the troubleshooting guide? [Y]

Expected result

  • tasks / tags without all scope: either default to vault-wide, or show a warning like “No active file — did you mean tasks all todo?”
  • Commands that print Error: should return a non-zero exit code
  • format=json should return valid JSON

Actual result

  • tasks total0 (should be 6 in Sandbox, 684 in main vault)
  • tasks todoNo tasks found. (should be 2 in Sandbox)
  • tags counts total0 (should be 1 in Sandbox)
  • All commands return exit code 0, even on error
  • No warning about missing active file context

Environment

  • Obsidian 1.12.1 (installer 1.11.4)
  • macOS Sonoma 14.3
  • CLI called from terminal (no active file)
  • Reproduced in Sandbox vault — no community plugins or themes

Additional information

These issues are especially impactful for programmatic/automation use cases. AI coding agents (Claude Code, Codex, Cursor) that call the CLI get “successful” responses with wrong results.

2 Likes

A shot in the dark but did you try with the latest installer (1.11.7) ? :woman_shrugging:

I’m a very basic CLI user :sweat_smile: … but from my tests, the “active file” scope does exist :thinking:
It’s the currently opened/focused file in the currently opened/focused vault in Obsidian (which should be open in the background before trying to interact with it through the CLI/TUI) if you didn’t explicitly target a specific vault with vault= ... .

It’s the same for the base:views: it requires a .base file to be open/focused on in Obsidian to work (otherwise you’ll get the error you’ve run into :blush:).


From my tests, it only returns 0 if the note focused on in Obsidian doesn’t contains any tasks…

I mean, I also get the same result when trying to run the same command and Obsidian is actually focused on Obsidian Sandbox > Start here.md

> tasks total 

0

But if I open Formatting/Task.md instead and run the command in the TUI, I get the expected result :blush:

> tasks total 

6

The “active file” default can be bypassed by targeting directly a note …

> tasks path="Formatting/Task.md" total

6

Edit: About the point 4: properties format=json returns YAML-like output instead of JSON

From the doc, the format option for properties only accepts yaml or tsv (yaml being the default)

tasks will be reworked in 1.12.2. Tasks all will not be necessary.
Please, open a new BR if you still have issues after you get 1.12.2

1 Like