can1357/oh-my-pi · error · SessionResolutionError
Failed to import ${sourceName} session: ${message}
Error message
Failed to import ${sourceName} session: ${message} What it means
Once a matching foreign session is found, main.ts calls `persistForeignSession(store, foreignSession, ...)` to convert and write it into omp's session store. Any error during conversion/persistence is rethrown as `SessionResolutionError: Failed to import <source> sessions: <message>`. The inner message carries the actual failure (parse error, write error, etc.).
Source
Thrown at packages/coding-agent/src/main.ts:1675
process.exit(0);
}
const foreignSession = foreignSessions.find(
session => session.id === selected.id && session.path === selected.path,
);
if (!foreignSession) {
throw new SessionResolutionError(`Selected ${sourceName} session is no longer available`);
}
try {
sessionManager = await logger.time(
`import${sourceName}Session`,
persistForeignSession,
store,
foreignSession,
{ fallbackCwd: cwd, sessionDir: parsedArgs.sessionDir },
);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new SessionResolutionError(`Failed to import ${sourceName} session: ${message}`);
}
} else {
sessionManager = await logger.time(
"createSessionManager",
createSessionManager,
parsedArgs,
cwd,
settingsInstance,
);
}
} catch (error: unknown) {
if (error instanceof SessionResolutionError) {
process.stderr.write(`${chalk.red(`Error: ${error.message}`)}\n`);
if (error.hint) {
process.stderr.write(`${chalk.dim(error.hint)}\n`);
}
process.exit(1);
}View on GitHub (pinned to 9690622007)
Solutions
- Read the wrapped inner message to identify the failing step (parse vs write) and the offending item.
- Update omp to the latest version — foreign session format changes are handled by newer importers.
- Try importing a different/older session to isolate a corrupt payload.
- Check the omp session directory (or `--session-dir`) is writable and has free space.
- As a workaround, copy essential context manually into a new omp session.
Example fix
// before omp --from-codex # importer fails on new session format // after bun install -g oh-my-pi@latest && omp --from-codex
Defensive patterns
Strategy: try-catch
Validate before calling
import * as fs from "node:fs";
// Ensure the destination session dir is writable with space before importing
fs.accessSync(sessionDir ?? defaultSessionDir, fs.constants.W_OK);
if (fs.statfsSync(sessionDir ?? defaultSessionDir).bavail * blockSize < minFreeBytes) throw new Error("Low disk space"); Try / catch
try {
await omp(["--from-codex"]);
} catch (err) {
if (err instanceof SessionResolutionError && err.message.startsWith("Failed to import")) {
console.error("Import failed; update omp or pick another session:", err.message);
} else throw err;
} Prevention
- Keep omp up to date so foreign-format changes are supported by the importer.
- Ensure the omp session dir (or --session-dir) is writable and has disk space.
- If a specific session fails repeatedly, treat it as corrupt and skip it.
When it happens
Trigger: `--from-claude`/`--from-codex` where importing a matched session throws: malformed/unparseable message payloads in the foreign session, unsupported content types, disk write failure into the omp session dir, or `sessionDir` unwritable.
Common situations: Foreign tool wrote session data in a newer format omp doesn't parse; session contains edge-case content (images, tool payloads) the importer can't map; full disk or read-only directory; custom `--session-dir` pointing somewhere unusable.
Related errors
- Failed to list ${sourceName} sessions: ${message}
- --from-claude and --from-codex cannot be used together
- --from-${source} cannot be combined with --continue, --resum
- --from-${foreignSource} is not supported in ${mode} mode
- Selected ${sourceName} session is no longer available
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/169c79d8e5c68371.
Report an issue: GitHub.