{"record":{"id":"283dc2fd5f1a6d4f","repo":"can1357/oh-my-pi","slug":"file-not-found-inputpath","errorCode":null,"errorMessage":"File not found: ${inputPath}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/export/html/index.ts","lineNumber":300,"sourceCode":"\t}\n\n\tconst palette = opts.palette ?? (opts.themeName ? \"theme\" : \"web\");\n\tconst html = await generateHtml(sessionData, palette, opts.themeNames, opts.themeName);\n\tconst outputPath = opts.outputPath || `${APP_NAME}-session-${path.basename(sessionFile, \".jsonl\")}.html`;\n\n\tawait Bun.write(outputPath, html);\n\treturn outputPath;\n}\n\n/** Export session file to HTML (standalone). */\nexport async function exportFromFile(inputPath: string, options?: ExportOptions | string): Promise<string> {\n\tconst opts: ExportOptions = typeof options === \"string\" ? { outputPath: options } : options || {};\n\n\tlet sm: SessionManager;\n\ttry {\n\t\tsm = await SessionManager.open(inputPath, undefined, undefined, { suppressBreadcrumb: true });\n\t} catch (err) {\n\t\tif (isEnoent(err)) throw new Error(`File not found: ${inputPath}`);\n\t\tthrow err;\n\t}\n\n\tconst sessionData: SessionData = {\n\t\theader: sessionHeaderForExport(sm.getHeader()),\n\t\tentries: sm.getEntries(),\n\t\tleafId: sm.getLeafId(),\n\t};\n\tif (opts.includeSubSessions !== false) {\n\t\tconst subSessions = await collectSubSessions(inputPath);\n\t\tif (Object.keys(subSessions).length > 0) sessionData.subSessions = subSessions;\n\t}\n\n\tconst palette = opts.palette ?? (opts.themeName ? \"theme\" : \"web\");\n\tconst html = await generateHtml(sessionData, palette, opts.themeNames, opts.themeName);\n\tconst outputPath = opts.outputPath || `${APP_NAME}-session-${path.basename(inputPath, \".jsonl\")}.html`;\n\n\tawait Bun.write(outputPath, html);","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/export/html/index.ts#L282-L318","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the path with ls (or check the sessions directory) and re-run with the exact absolute path.","Use the session list to copy the correct filename — session files live under the agent sessions dir.","Quote the path if it contains spaces (and remember /export only accepts one path token).","Confirm the file is a session JSONL, not a directory or other artifact."],"exampleFix":"// before\nawait exportFromFile(\"~/.omp/sesions/abc.jsonl\"); // typo\n// after\nawait exportFromFile(\"/home/me/.omp/agent/sessions/abc.jsonl\");","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nif (!existsSync(inputPath)) {\n  throw new Error(`Session file not found: ${inputPath}`);\n}\nawait exportFromFile(inputPath);","typeGuard":"null","tryCatchPattern":"try {\n  await exportFromFile(inputPath);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"File not found:\")) {\n    console.error(`${err.message}\\nList sessions to get the exact path.`);\n  } else throw err;\n}","preventionTips":["Copy session paths from the session list rather than typing them.","Use absolute paths to avoid cwd surprises.","Confirm old sessions weren't cleaned up before referencing them."],"tags":["filesystem","export","path","enoent"],"backgroundTag":"file-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}