{"record":{"id":"5bcf016a61f4a573","repo":"davila7/claude-code-templates","slug":"invalid-session-file-missing-conversation-data","errorCode":null,"errorMessage":"Invalid session file - missing conversation data","messagePattern":"Invalid session file - missing conversation data","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli-tool/src/session-sharing.js","lineNumber":338,"sourceCode":"      if (error.message.includes('Unexpected token')) {\n        throw new Error('Invalid session file - corrupted or not a Claude Code session');\n      }\n      throw error;\n    }\n  }\n\n  /**\n   * Validate session data structure\n   * @param {Object} sessionData - Session data to validate\n   * @throws {Error} If validation fails\n   */\n  validateSessionData(sessionData) {\n    if (!sessionData.version) {\n      throw new Error('Invalid session file - missing version');\n    }\n\n    if (!sessionData.conversation || !sessionData.conversation.id) {\n      throw new Error('Invalid session file - missing conversation data');\n    }\n\n    if (!sessionData.messages || !Array.isArray(sessionData.messages)) {\n      throw new Error('Invalid session file - missing or invalid messages');\n    }\n\n    if (sessionData.messages.length === 0) {\n      throw new Error('Invalid session file - no messages found');\n    }\n  }\n\n  /**\n   * Install session in Claude Code directory structure\n   * @param {Object} sessionData - Session data to install\n   * @param {Object} options - Installation options\n   * @returns {Promise<Object>} Installation result\n   */\n  async installSession(sessionData, options = {}) {","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/session-sharing.js#L320-L356","documentation":"Thrown by validateSessionData() in cli-tool/src/session-sharing.js when the session object has no 'conversation' object or the conversation is missing its 'id'. cloneSession needs the conversation id to place the session into Claude Code's project directory structure, so a session without it cannot be installed.","triggerScenarios":"Calling cloneSession()/validateSessionData() on a session export whose 'conversation' field is absent, null, or an object without 'id' — typically a truncated export, a different JSON file, or a schema drift after a Claude Code update.","commonSituations":"Session exports created by an older/newer Claude Code version with a changed schema; manually edited exports where the conversation block was removed; downloading a partial file that JSON-parses by luck.","solutions":["Check sessionData.conversation in the downloaded file — if absent, re-export and re-share the session with a current CLI version","Confirm the whole file downloaded (compare file size with the sender)","If schema changed upstream, update session-sharing.js to map the new conversation field"],"exampleFix":"// before\nif (!sessionData.conversation || !sessionData.conversation.id) {\n  throw new Error('Invalid session file - missing conversation data');\n}\n\n// after\nconst convId = sessionData.conversation?.id || sessionData.conversationId;\nif (!convId) {\n  throw new Error('Invalid session file - missing conversation data');\n}","handlingStrategy":"type-guard","validationCode":"if (!data.conversation || !data.conversation.id) {\n  throw new Error('Rejecting file: no conversation.id — cannot install session');\n}","typeGuard":"function hasConversationId(d) {\n  return Boolean(d && d.conversation && typeof d.conversation.id === 'string' && d.conversation.id.length > 0);\n}","tryCatchPattern":"try {\n  await cloner.cloneSession(data);\n} catch (e) {\n  if (e.message.includes('missing conversation data')) {\n    // regenerate the export from the source session\n    return reExport(originalSession);\n  }\n  throw e;\n}","preventionTips":["Guard conversation.id before clone to give a clearer message","Keep sender and receiver CLI versions aligned to avoid schema drift"],"tags":["validation","session-sharing","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}