can1357/oh-my-pi · error · Error

File not found: ${inputPath}

Error message

File not found: ${inputPath}

What it means

exportFromFile opens a session JSONL file via SessionManager.open; if the open fails with an ENOENT (file does not exist), it is converted into this human-readable 'File not found: <path>' error. Other open failures are rethrown unchanged. It exists to give the /export CLI a clear message when the user passes a bad path.

Source

Thrown at packages/coding-agent/src/export/html/index.ts:300

	}

	const palette = opts.palette ?? (opts.themeName ? "theme" : "web");
	const html = await generateHtml(sessionData, palette, opts.themeNames, opts.themeName);
	const outputPath = opts.outputPath || `${APP_NAME}-session-${path.basename(sessionFile, ".jsonl")}.html`;

	await Bun.write(outputPath, html);
	return outputPath;
}

/** Export session file to HTML (standalone). */
export async function exportFromFile(inputPath: string, options?: ExportOptions | string): Promise<string> {
	const opts: ExportOptions = typeof options === "string" ? { outputPath: options } : options || {};

	let sm: SessionManager;
	try {
		sm = await SessionManager.open(inputPath, undefined, undefined, { suppressBreadcrumb: true });
	} catch (err) {
		if (isEnoent(err)) throw new Error(`File not found: ${inputPath}`);
		throw err;
	}

	const sessionData: SessionData = {
		header: sessionHeaderForExport(sm.getHeader()),
		entries: sm.getEntries(),
		leafId: sm.getLeafId(),
	};
	if (opts.includeSubSessions !== false) {
		const subSessions = await collectSubSessions(inputPath);
		if (Object.keys(subSessions).length > 0) sessionData.subSessions = subSessions;
	}

	const palette = opts.palette ?? (opts.themeName ? "theme" : "web");
	const html = await generateHtml(sessionData, palette, opts.themeNames, opts.themeName);
	const outputPath = opts.outputPath || `${APP_NAME}-session-${path.basename(inputPath, ".jsonl")}.html`;

	await Bun.write(outputPath, html);

View on GitHub (pinned to 9690622007)

Solutions

  1. Verify the path with ls (or check the sessions directory) and re-run with the exact absolute path.
  2. Use the session list to copy the correct filename — session files live under the agent sessions dir.
  3. Quote the path if it contains spaces (and remember /export only accepts one path token).
  4. Confirm the file is a session JSONL, not a directory or other artifact.

Example fix

// before
await exportFromFile("~/.omp/sesions/abc.jsonl"); // typo
// after
await exportFromFile("/home/me/.omp/agent/sessions/abc.jsonl");
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "node:fs";
if (!existsSync(inputPath)) {
  throw new Error(`Session file not found: ${inputPath}`);
}
await exportFromFile(inputPath);

Type guard

null

Try / catch

try {
  await exportFromFile(inputPath);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("File not found:")) {
    console.error(`${err.message}\nList sessions to get the exact path.`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling exportFromFile(path) — or `/export <path>` — with a session file path that doesn't exist: typo, wrong directory, file deleted/moved, or passing a directory instead of a session JSONL.

Common situations: Hand-typing a session path from memory; referencing a session after cleanup of old sessions; relative path resolved from a different cwd than expected; pasting a URL/ID instead of a filesystem path.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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