{"record":{"id":"8766db73d1e02a27","repo":"affaan-m/ECC","slug":"claude-session-not-found-explicittarget","errorCode":null,"errorMessage":"Claude session not found: ${explicitTarget}","messagePattern":"Claude session not found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/claude-history.js","lineNumber":89,"sourceCode":"          value: 'latest'\n        }\n      };\n    }\n\n    const alias = sessionAliases.resolveAlias(explicitTarget);\n    if (alias) {\n      return {\n        session: hydrateSessionFromPath(alias.sessionPath),\n        sourceTarget: {\n          type: 'claude-alias',\n          value: explicitTarget\n        }\n      };\n    }\n\n    const session = sessionManager.getSessionById(explicitTarget, true);\n    if (!session) {\n      throw new Error(`Claude session not found: ${explicitTarget}`);\n    }\n\n    return {\n      session,\n      sourceTarget: {\n        type: 'claude-history',\n        value: explicitTarget\n      }\n    };\n  }\n\n  if (isSessionFileTarget(target, cwd)) {\n    return {\n      session: hydrateSessionFromPath(path.resolve(cwd, target)),\n      sourceTarget: {\n        type: 'session-file',\n        value: path.resolve(cwd, target)\n      }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/session-adapters/claude-history.js#L71-L107","documentation":"resolveSessionRecord throws this when parseClaudeTarget returns an explicit target (a session id/filename) but sessionManager.getSessionById(explicitTarget, true) returns null. The requested Claude session does not exist in the local history store.","triggerScenarios":"Calling resolveSessionRecord with a specific Claude session identifier (not 'latest', not a file path) that getSessionById cannot find — misspelled id, session from another project, or session deleted from disk.","commonSituations":"Pasting a session id from another machine or project; referencing a session after ~/.claude history cleanup; typo in a UUID or trailing whitespace/newline in a CI variable holding the id.","solutions":["Print sessionManager.getAllSessions() and copy the exact filename/id from the list.","Confirm the session belongs to the current project (lookup is cwd-scoped).","Trim the target string of whitespace; pass a path to the session .jsonl file as a fallback.","Recreate the session if history was deleted — there is no remote restore.","Check for version drift: session filenames changed shape across Claude Code versions."],"exampleFix":"// before\nadapter.resolveSessionRecord('a1b2c3d4-e5f6'); // typo'd id -> throws\n// after\nconst id = process.env.CLAUDE_SESSION_ID.trim();\nconst known = sessionManager.getAllSessions().sessions.find(s => s.filename === id);\nif (!known) throw new Error(`Unknown session; available: ${sessionManager.getAllSessions().sessions.map(s => s.filename).join(', ')}`);","handlingStrategy":"validation","validationCode":"const all = sessionManager.getAllSessions().sessions;\nif (!all.some(s => s.filename === targetId)) throw new Error(`Unknown session id: ${targetId}; valid ids: ${all.map(s => s.filename).join(', ')}`);","typeGuard":"function isKnownSession(id, sessions) { return typeof id === 'string' && sessions.some(s => s.filename === id); }","tryCatchPattern":"try { return adapter.resolveSessionRecord(id); } catch (e) { if (/^Claude session not found:/.test(e.message)) throw new Error(`Pick a session from getAllSessions(); '${id}' not found`); throw e; }","preventionTips":["Copy ids directly from getAllSessions output","Trim and validate id format before lookup","Reference sessions only on the machine/project where they were created","Avoid assuming history survives cleanup policies"],"tags":["session","claude","not-found"],"backgroundTag":"entity-not-found","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"}