{"record":{"id":"160410afaeefe976","repo":"affaan-m/ECC","slug":"unsupported-opencode-session-target-target","errorCode":null,"errorMessage":"Unsupported OpenCode session target: ${target}","messagePattern":"Unsupported OpenCode session target: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/opencode.js","lineNumber":154,"sourceCode":"    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\n  if (isOpencodeSessionFileTarget(target, cwd)) {\n    const absoluteTarget = path.resolve(cwd, target);\n    return { sessionInfoPath: absoluteTarget, sourceTarget: { type: 'opencode-session-file', value: absoluteTarget } };\n  }\n\n  throw new Error(`Unsupported OpenCode session target: ${target}`);\n}\n\nfunction readMessageFiles(messageDir) {\n  if (!fs.existsSync(messageDir) || !fs.statSync(messageDir).isDirectory()) {\n    return [];\n  }\n\n  try {\n    return fs.readdirSync(messageDir)\n      .filter(name => name.startsWith('msg_') && name.endsWith('.json'))\n      .map(name => path.join(messageDir, name));\n  } catch {\n    return [];\n  }\n}\n\nfunction deriveModelFromMessages(messageFiles) {\n  for (const filePath of messageFiles.slice(0, MAX_MESSAGE_SCAN)) {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/session-adapters/opencode.js#L136-L172","documentation":"resolveSessionInfoPath exhausted all branches: the target is not 'latest', not an explicit id with a matching file, and isOpencodeSessionFileTarget(target,cwd) returned false (file does not exist, is not a file, or isSessionInfoFile rejected it). The OpenCode adapter cannot interpret the target string.","triggerScenarios":"Passing a target that is neither an OpenCode id nor a path to an existing session-info file (e.g. a project name, directory, or arbitrary JSON file). The referenced file does not exist. The file does not satisfy isSessionInfoFile (wrong location or naming).","commonSituations":"User passes a bare project name or message id. Relative path resolved against the wrong cwd. File is present but in a location isSessionInfoFile does not recognize.","solutions":["Use one of the supported forms: 'latest', an OpenCode session id, or an absolute/relative path to an existing session-info file.","Confirm the path exists and isSessionInfoFile accepts it.","Pass the correct cwd for relative paths.","For structured targets, pass { type: 'opencode', value: <id-or-path> }."],"exampleFix":"// before\nadapter.open('opencode:my-project', { cwd }); // unsupported\n\n// after\nadapter.open('opencode:latest', { cwd });\n// or\nadapter.open('/abs/path/to/session-info.json', { cwd });\n// or structured\nadapter.open({ type: 'opencode', value: '/abs/path/to/session-info.json' }, { cwd });","handlingStrategy":"validation","validationCode":"function assertOpencodeTargetShape(target, cwd) {\n  if (target === 'latest') return;\n  const abs = path.resolve(cwd, target);\n  const isFile = fs.existsSync(abs) && fs.statSync(abs).isFile() && isSessionInfoFile(abs);\n  const byId = findSessionInfoById(resolveStorageDir({}, {}), target);\n  if (!isFile && !byId) {\n    throw new Error(`Unsupported OpenCode target: ${target}. Use 'latest', a session id, or a session-info path.`);\n  }\n}","typeGuard":"function isOpencodeTargetPlausible(target, cwd) {\n  if (target === 'latest') return true;\n  if (typeof target !== 'string') return false;\n  const abs = path.resolve(cwd, target);\n  return fs.existsSync(abs) && fs.statSync(abs).isFile() && isSessionInfoFile(abs);\n}","tryCatchPattern":"try { return resolveSessionInfoPath(target, cwd, options, context); }\ncatch (err) {\n  if (err.message.startsWith('Unsupported OpenCode session target:')) {\n    throw new Error(`${err.message}. Supported: 'latest' | session id | path to a session-info file.`);\n  }\n  throw err;\n}","preventionTips":["Pass an absolute session-info path when unsure.","Use structured targets {type:'opencode', value:path} for clarity.","Confirm isSessionInfoFile accepts the file before resolving."],"tags":["opencode","session-resolution","unsupported-target"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}