affaan-m/ECC · error · Error
No OpenCode sessions found
Error message
No OpenCode sessions found
What it means
resolveSessionInfoPath in the OpenCode adapter throws this when target 'latest' is requested but findLatestSessionInfo(storageDir) finds no session info files under the OpenCode storage directory. There is no recent OpenCode session to resolve.
Solutions
- Launch OpenCode once to create a session under its storage directory.
- Verify resolveStorageDir options/env (XDG_DATA_HOME or explicit storageDir) point at the real storage location.
- Pass an explicit session id or a session info file path instead of 'latest'.
- Check the installed OpenCode version's storage layout matches what this adapter expects.
- Check permissions on the storage directory.
Example fix
// before
const { sessionInfoPath } = oc.resolveSessionInfoPath('latest'); // throws when storage empty
// after
const storage = path.join(process.env.XDG_DATA_HOME || path.join(os.homedir(), '.local/share'), 'opencode', 'storage', 'session');
if (!fs.existsSync(storage)) throw new Error('No OpenCode storage found; run `opencode` first or fix the storage dir'); Defensive patterns
Strategy: fallback
Validate before calling
const dir = resolveStorageDir();
if (!fs.existsSync(dir)) throw new Error('OpenCode storage dir missing; run opencode first or fix storage dir'); Type guard
function hasSessions(dir) { return fs.existsSync(dir) && fs.readdirSync(dir, { recursive: true }).some(f => String(f).endsWith('.json')); } Try / catch
try { return adapter.resolveSessionInfoPath('latest'); } catch (e) { if (e.message === 'No OpenCode sessions found') return null; throw e; } Prevention
- Launch OpenCode once before resolving 'latest'
- Set XDG_DATA_HOME consistently between runs
- Pass explicit session ids in CI
- Check adapter version vs OpenCode storage layout
When it happens
Trigger: resolveSessionInfoPath called with explicitTarget === 'latest' while the resolved storage dir (~/.local/share/opencode/storage or options-overridden) contains no session metadata files or does not exist.
Common situations: OpenCode never launched on this machine/CI container; XDG_DATA_HOME redirected to an empty location; storage wiped between container runs; OpenCode version changed its storage layout so the finder looks in the wrong subdirectory.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- OpenCode session not 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/205ee5cc49618046.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/session-adapters/opencode.js:130
return files
.map(filePath => ({ filePath, updatedMs: readSessionUpdatedMs(filePath) }))
.sort((a, b) => b.updatedMs - a.updatedMs)[0].filePath;
}
function findSessionInfoById(storageDir, sessionId) {
return listSessionInfoFiles(storageDir)
.find(filePath => path.basename(filePath, '.json') === sessionId) || null;
}
function resolveSessionInfoPath(target, cwd, options, context) {
const explicitTarget = parseOpencodeTarget(target);
const storageDir = resolveStorageDir(options, context);
if (explicitTarget) {
if (explicitTarget === 'latest') {
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}`);
}
View on GitHub (pinned to 8321021c54)