{"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":"exception","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/session-adapters/opencode.js#L112-L148","documentation":"resolveSessionInfoPath was called with target 'latest' (or opencode:latest) but findLatestSessionInfo(storageDir) returned null. The OpenCode adapter found no session-info JSON files in the resolved OpenCode storage directory.","triggerScenarios":"Requesting the latest OpenCode session on a machine where OpenCode has never run, or where the storage directory is set to an empty/non-existent path. OPENCODE storage root or the project id is overridden so resolveStorageDir points elsewhere.","commonSituations":"Fresh environment with no OpenCode sessions. CI container with isolated HOME lacking the OpenCode storage dir. Project id passed via context does not match any stored session. OpenCode version writes to a different storage layout.","solutions":["Run OpenCode at least once so it creates a session-info file, then retry 'latest'.","Verify the storage directory resolveStorageDir points at exists and contains session info JSON files.","If the storage root or project id is overridden, set them to the values that actually hold the sessions.","Pass an explicit session id or absolute path instead of 'latest'."],"exampleFix":"// before\nadapter.open('opencode:latest', { cwd });\n\n// after\nadapter.open('opencode:<known-session-id>', { cwd });\n// or run `opencode` once to seed the storage directory, then retry 'latest'","handlingStrategy":"validation","validationCode":"const latest = findLatestSessionInfo(storageDir);\nif (!latest) {\n  throw new Error(`No OpenCode sessions in ${storageDir}; run 'opencode' first or pass an explicit session id.`);\n}","typeGuard":"function hasAnyOpencodeSession(storageDir) {\n  return listSessionInfoFiles(storageDir).length > 0;\n}","tryCatchPattern":"try { return resolveSessionInfoPath('latest', cwd, options, context); }\ncatch (err) {\n  if (err.message === 'No OpenCode sessions found') {\n    throw new Error('No OpenCode sessions found. Pass an explicit session id or session-info path.');\n  }\n  throw err;\n}","preventionTips":["Run OpenCode once before scripting against 'latest'.","Confirm the storage root and project id resolve to the dir holding session-info files.","Prefer explicit ids in automation."],"tags":["opencode","session-resolution","empty-state"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}