obsidian: 'note open' overwrites the active note (PUT /active/ with the path as body)
Summary
cli-anything-obsidian note open <path> is implemented as PUT /active/ with the request body set to the path string (obsidian/agent-harness/cli_anything/obsidian/core/note.py, open_note).
On the Obsidian Local REST API, PUT /active/ replaces the content of the currently active file. So the command does not open anything — it overwrites whatever note the user currently has open, replacing its content with the literal path string (e.g. Projects/foo.md). When no note is active it returns 404, which masks the bug during casual testing.
Repro
- Open any note in Obsidian.
cli-anything-obsidian --json note open "Some/Other.md"- The note from step 1 now contains only the text
Some/Other.md.
Expected
Open the target note via the Local REST API "Open" endpoint: POST /open/{path}.
Fix (verified against Local REST API plugin 5.1.0, Obsidian 1.12.7, Windows)
from cli_anything.obsidian.utils.obsidian_backend import api_get, api_post
def open_note(base_url: str, api_key: str, path: str) -> dict:
return api_post(base_url, f"/open/{path.lstrip('/')}", api_key)
After this change note open returns {"status": "ok"}, note active returns the opened note, and the previously active note is untouched.
Related
server status exits 0 with a wrong API key — authenticated: false is only in the JSON body. Agents following the README's "verify with server status before other commands" get a false pass; consider a non-zero exit when authenticated is false.
Version: cli-anything-obsidian 1.1.0 (PyPI). HEAD core/note.py has the same code.
Source: HKUDS/CLI-Anything