{"record":{"id":"205ee5cc49618046","repo":"affaan-m/ECC","slug":"no-opencode-sessions-found","errorCode":null,"errorMessage":"No OpenCode sessions found","messagePattern":"No OpenCode sessions found","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/opencode.js","lineNumber":130,"sourceCode":"  return files\n    .map(filePath => ({ filePath, updatedMs: readSessionUpdatedMs(filePath) }))\n    .sort((a, b) => b.updatedMs - a.updatedMs)[0].filePath;\n}\n\nfunction findSessionInfoById(storageDir, sessionId) {\n  return listSessionInfoFiles(storageDir)\n    .find(filePath => path.basename(filePath, '.json') === sessionId) || null;\n}\n\nfunction resolveSessionInfoPath(target, cwd, options, context) {\n  const explicitTarget = parseOpencodeTarget(target);\n  const storageDir = resolveStorageDir(options, context);\n\n  if (explicitTarget) {\n    if (explicitTarget === 'latest') {\n      const latest = findLatestSessionInfo(storageDir);\n      if (!latest) {\n        throw new Error('No OpenCode sessions found');\n      }\n\n      return { sessionInfoPath: latest, sourceTarget: { type: 'opencode', value: 'latest' } };\n    }\n\n    const absoluteExplicit = path.resolve(cwd, explicitTarget);\n    if (fs.existsSync(absoluteExplicit) && isSessionInfoFile(absoluteExplicit)) {\n      return { sessionInfoPath: absoluteExplicit, sourceTarget: { type: 'opencode-session-file', value: absoluteExplicit } };\n    }\n\n    const byId = findSessionInfoById(storageDir, explicitTarget);\n    if (byId) {\n      return { sessionInfoPath: byId, sourceTarget: { type: 'opencode', value: explicitTarget } };\n    }\n\n    throw new Error(`OpenCode session not found: ${explicitTarget}`);\n  }\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/session-adapters/opencode.js#L112-L148","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst { sessionInfoPath } = oc.resolveSessionInfoPath('latest'); // throws when storage empty\n// after\nconst storage = path.join(process.env.XDG_DATA_HOME || path.join(os.homedir(), '.local/share'), 'opencode', 'storage', 'session');\nif (!fs.existsSync(storage)) throw new Error('No OpenCode storage found; run `opencode` first or fix the storage dir');","handlingStrategy":"fallback","validationCode":"const dir = resolveStorageDir();\nif (!fs.existsSync(dir)) throw new Error('OpenCode storage dir missing; run opencode first or fix storage dir');","typeGuard":"function hasSessions(dir) { return fs.existsSync(dir) && fs.readdirSync(dir, { recursive: true }).some(f => String(f).endsWith('.json')); }","tryCatchPattern":"try { return adapter.resolveSessionInfoPath('latest'); } catch (e) { if (e.message === 'No OpenCode sessions found') return null; throw e; }","preventionTips":["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"],"tags":["session","opencode","not-found"],"backgroundTag":"empty-result-set","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}