can1357/oh-my-pi · error · ToolError

`path` must contain non-empty globs or paths

Error message

`path` must contain non-empty globs or paths

What it means

After normalizing all path entries (including resolved internal URLs), the tool checks that none resolved to an empty string. An empty pattern entry is unsearchable and usually signals a mangled input, so it is rejected with this ToolError before any filesystem work.

Source

Thrown at packages/coding-agent/src/tools/glob.ts:255

					);
					continue;
				}
				const resource = await internalRouter.resolve(rawPattern, {
					cwd: this.session.cwd,
					settings: this.session.settings,
					signal,
					sessionFile: this.session.getSessionFile() ?? undefined,
					localProtocolOptions: this.session.localProtocolOptions,
					skills: this.session.skills,
					pathOnly: true,
				});
				if (!resource.sourcePath) {
					throw new ToolError(`Cannot find internal URL without a backing file: ${rawPattern}`);
				}
				normalizedPatterns.push(resource.sourcePath);
			}
			if (normalizedPatterns.some(pattern => pattern.length === 0)) {
				throw new ToolError("`path` must contain non-empty globs or paths");
			}

			// Tolerate missing entries in a multi-path call: skip ones whose base
			// directory is gone, and only error if every entry is missing. Single
			// missing path keeps the original ENOENT semantics — the user explicitly
			// asked about that one path, so silent empty results would be misleading.
			let missingPaths: string[] = [];
			let effectivePatterns = normalizedPatterns;
			if (normalizedPatterns.length > 1 && !this.#customOps) {
				const partition = await partitionExistingPaths(normalizedPatterns, this.session.cwd, parseFindPattern);
				if (partition.valid.length === 0) {
					throw new ToolError(`Path not found: ${partition.missing.join(", ")}`);
				}
				effectivePatterns = partition.valid;
				missingPaths = partition.missing;
			}

			const multiPattern = await resolveExplicitFindPatterns(effectivePatterns, this.session.cwd);

View on GitHub (pinned to 9690622007)

Solutions

  1. Filter empty strings out of the path array before calling
  2. Provide at least one non-empty glob or directory path
  3. Fix the delimiter pattern so it doesn't yield empty segments

Example fix

// before
await findTool({ path: ["", "src"] });
// after
await findTool({ path: ["src"] }); // or filter(p => p.length > 0)
Defensive patterns

Strategy: validation

Validate before calling

const paths = (Array.isArray(path) ? path : [path]).map(p => (p ?? "").trim()).filter(p => p.length > 0);
if (paths.length === 0) throw new Error("path must contain at least one non-empty entry");

Type guard

const isNonEmptyPathEntry = (p: unknown): p is string => typeof p === "string" && p.trim().length > 0;

Try / catch

try {
  await globTool({ path });
} catch (err) {
  if (err instanceof ToolError && err.message.includes("must contain non-empty globs or paths")) {
    await globTool({ path: path.filter(p => p && p.length > 0) });
  } else throw err;
}

Prevention

When it happens

Trigger: Passing path: [''] or an entry that normalizes/resolves to '' — e.g. an empty string after alias resolution, an empty memory:// glob base, or expandDelimitedPathEntries producing a zero-length entry (e.g. a lone delimiter).

Common situations: Env vars or config fields defaulting to empty string and interpolated into path arrays; splitting a string like 'src/' with a pattern producing a trailing empty entry; JSON payloads with "path": [""].

Related errors


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