can1357/oh-my-pi · error

vault:// active vault path was empty

Error message

vault:// active vault path was empty

What it means

For vault:// URLs using the active-vault shorthand ("_"), the handler shells out to `obsidian vault info path` and parses the stdout for the active vault path. If parseActiveVaultPath() returns an empty string — meaning the CLI produced no recognizable path line — the handler throws this error rather than resolving to an invalid root. It indicates the Obsidian CLI answered but yielded no usable vault path.

Source

Thrown at packages/coding-agent/src/internal-urls/vault-protocol.ts:740

	async #loadVaultDirectory(context?: ResolveContext | WriteContext): Promise<Map<string, string>> {
		if (cachedVaultDirectory) return cachedVaultDirectory;
		const result = await this.#spawn(["vaults", "verbose"], context);
		assertCliSuccess("vaults", result);
		cachedVaultDirectory = parseVaultDirectory(result.stdout);
		return cachedVaultDirectory;
	}

	async #resolveVaultRoot(ref: VaultReference, context?: ResolveContext | WriteContext): Promise<string> {
		const cached = getCachedVaultRoot(ref);
		if (cached) return cached;

		if (ref.active) {
			const result = await this.#spawn(["vault", "info", "path"], context);
			assertCliSuccess("vault info path", result);
			const activePath = parseActiveVaultPath(result.stdout);
			if (!activePath) {
				throw new Error("vault:// active vault path was empty");
			}
			cachedActiveVaultPath = path.resolve(activePath);
			return cachedActiveVaultPath;
		}

		if (!ref.vault) {
			throw new Error("vault:// URL requires a vault name or '_' for the active vault");
		}
		const vaults = await this.#loadVaultDirectory(context);
		const root = vaults.get(ref.vault);
		if (!root) {
			const available = Array.from(vaults.keys()).sort().join(", ") || "none";
			throw new Error(`Unknown Obsidian vault: ${ref.vault}\nAvailable: ${available}`);
		}
		return path.resolve(root);
	}

	#vaultCliArg(ref: VaultReference): string[] {

View on GitHub (pinned to 9690622007)

Solutions

  1. Open a vault in Obsidian so the CLI reports an active vault, then retry.
  2. Run `obsidian vault info path` manually to inspect the raw output; if the format changed, upgrade the Obsidian CLI/binary to a compatible version.
  3. Reference an explicit vault name (vault://MyVault/...) instead of the "_" active-vault shorthand.

Example fix

// before
const res = await resolveInternalUrl("vault://_/note.md"); // active vault unresolved
// after
const res = await resolveInternalUrl("vault://MyVault/note.md"); // explicit vault
Defensive patterns

Strategy: try-catch

Validate before calling

import { $ } from "bun";
const info = await $`obsidian vault info path`.quiet().nothrow();
const usable = info.exitCode === 0 && info.text().trim().length > 0;
if (!usable) throw new Error("Obsidian CLI reports no active vault; open one or name the vault explicitly");

Try / catch

try {
  const root = await resolveVaultRoot(ref, ctx);
} catch (err) {
  if (err instanceof Error && err.message.includes("active vault path was empty")) {
    // fall back to an explicit vault name or prompt the user to open a vault
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: Resolving a vault://_/... URL when `obsidian vault info path` succeeds (exit 0) but its stdout contains no "path" line and either has multiple lines or is empty, so parseActiveVaultPath returns "".

Common situations: Obsidian CLI versions whose output format changed; an Obsidian installation with no vault open/focused; wrappers or plugins that add extra output around the path line.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/686b68872f024bea. Report an issue: GitHub.