affaan-m/ECC · error · Error
OpenCode session not found
Error message
OpenCode session not found: ${explicitTarget} What it means
resolveSessionInfoPath throws this when an explicit OpenCode session identifier was provided but findSessionInfoById(storageDir, explicitTarget) found no matching session info file, and the target is not directly a session file path. The referenced OpenCode session does not exist locally.
Solutions
- List session info files under the storage dir and use an exact id from a filename.
- Pass the full path to the session info JSON file instead of an id.
- Verify the storage dir resolution points at the machine where the session was created.
- Trim the id; check for copy/paste truncation.
- Recreate the session if its storage was deleted.
Example fix
// before
resolve('ses_abc123'); // unknown id -> throws
// after
const available = fs.readdirSync(storageDir).filter(f => f.endsWith('.json'));
if (!available.some(f => f.replace(/\.json$/, '') === id)) {
throw new Error(`OpenCode session '${id}' not found. Available: ${available.join(', ')}`);
}
resolve(id); Defensive patterns
Strategy: validation
Validate before calling
const available = fs.readdirSync(storageDir).filter(f => f.endsWith('.json'));
if (!available.some(f => f.replace(/\.json$/, '') === sessionId)) throw new Error(`Session '${sessionId}' not in ${storageDir}`); Type guard
function isKnownOpencodeSession(id, files) { return typeof id === 'string' && files.some(f => f.replace(/\.json$/, '') === id); } Try / catch
try { return adapter.resolveSessionInfoPath(id); } catch (e) { if (/^OpenCode session not found:/.test(e.message)) throw new Error(`List storage dir contents; '${id}' not found`); throw e; } Prevention
- Use ids copied from the storage directory on the same machine
- Trim ids and watch for truncation
- Pass the session JSON path when unsure of id format
- Expect sessions to vanish after storage cleanup
When it happens
Trigger: resolveSessionInfoPath called with explicitTarget set to a session id with no corresponding info file under storageDir — id from another machine, deleted session, or wrong storage dir.
Common situations: Sharing session ids between teammates without sharing storage; storage cleanup removing old sessions; passing a Claude/Codex id to the OpenCode adapter; case or truncation errors in the id.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- No OpenCode sessions found
- Claude session not found
- Codex rollout session not found
- No Claude session history found
- No Codex rollout sessions found
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/19c03deeabd5eacc.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/session-adapters/opencode.js:146
const latest = findLatestSessionInfo(storageDir);
if (!latest) {
throw new Error('No OpenCode sessions found');
}
return { sessionInfoPath: latest, sourceTarget: { type: 'opencode', value: 'latest' } };
}
const absoluteExplicit = path.resolve(cwd, explicitTarget);
if (fs.existsSync(absoluteExplicit) && isSessionInfoFile(absoluteExplicit)) {
return { sessionInfoPath: absoluteExplicit, sourceTarget: { type: 'opencode-session-file', value: absoluteExplicit } };
}
const byId = findSessionInfoById(storageDir, explicitTarget);
if (byId) {
return { sessionInfoPath: byId, sourceTarget: { type: 'opencode', value: explicitTarget } };
}
throw new Error(`OpenCode session not found: ${explicitTarget}`);
}
if (isOpencodeSessionFileTarget(target, cwd)) {
const absoluteTarget = path.resolve(cwd, target);
return { sessionInfoPath: absoluteTarget, sourceTarget: { type: 'opencode-session-file', value: absoluteTarget } };
}
throw new Error(`Unsupported OpenCode session target: ${target}`);
}
function readMessageFiles(messageDir) {
if (!fs.existsSync(messageDir) || !fs.statSync(messageDir).isDirectory()) {
return [];
}
try {
return fs.readdirSync(messageDir)
.filter(name => name.startsWith('msg_') && name.endsWith('.json'))View on GitHub (pinned to 8321021c54)