{"record":{"id":"48737fbad1ba1c5d","repo":"slopus/happy","slug":"happy-session-session-id-is-missing-its-claude","errorCode":null,"errorMessage":"Happy session ${session.id} is missing its Claude session ID.","messagePattern":"Happy session (.+?) is missing its Claude session ID\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/resume/handleResumeCommand.ts","lineNumber":73,"sourceCode":"    const flavor = resolveFlavor(metadata);\n\n    if (flavor === 'codex') {\n        if (!metadata.codexThreadId) {\n            throw new Error(`Happy session ${session.id} is missing its Codex thread ID.`);\n        }\n        const args = ['codex', '--resume', metadata.codexThreadId];\n        if (options.startedBy) {\n            args.push('--started-by', options.startedBy);\n        }\n        return {\n            cwd: metadata.path,\n            args,\n        };\n    }\n\n    if (flavor === 'claude') {\n        if (!metadata.claudeSessionId) {\n            throw new Error(`Happy session ${session.id} is missing its Claude session ID.`);\n        }\n        const args = ['claude'];\n        if (options.claudeStartingMode) {\n            args.push('--happy-starting-mode', options.claudeStartingMode);\n        }\n        if (options.startedBy) {\n            args.push('--started-by', options.startedBy);\n        }\n        args.push('--resume', metadata.claudeSessionId);\n        return {\n            cwd: metadata.path,\n            args,\n        };\n    }\n\n    throw new Error(`Happy session ${session.id} uses unsupported flavor \"${metadata.flavor ?? 'unknown'}\".`);\n}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/resume/handleResumeCommand.ts#L55-L91","documentation":"buildResumeLaunch throws this when a session's resolved flavor is 'claude' but its metadata lacks claudeSessionId. Resuming a Claude session requires the original Claude session ID so the CLI can spawn `claude` pointed at that session; without it resume cannot proceed.","triggerScenarios":"Calling buildResumeLaunch (directly or via handleResumeCommand/launch) with a ResumableHappySession whose metadata.flavor resolves to 'claude' while metadata.claudeSessionId is undefined/null — typically metadata persisted before claudeSessionId was recorded.","commonSituations":"Sessions created by older happy-cli versions before claudeSessionId was included; metadata corruption or truncated decryption; sessions started outside the happy wrapper and later registered without full metadata.","solutions":["Start a new Happy session with the current CLI so claudeSessionId is persisted","Verify the installed happy-cli version supports capturing claudeSessionId and upgrade if not","Resume manually with `claude --resume <session-id>` if you can locate the ID in ~/.claude/projects","Delete the stale session record if it is unrecoverable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function canResumeClaude(s: ResumableHappySession): boolean {\n  return resolveFlavor(s.metadata) === 'claude' && typeof s.metadata.claudeSessionId === 'string' && s.metadata.claudeSessionId.length > 0;\n}","typeGuard":"function hasClaudeSessionId(m: Metadata): m is Metadata & { claudeSessionId: string } {\n  return typeof (m as any).claudeSessionId === 'string' && (m as any).claudeSessionId.length > 0;\n}","tryCatchPattern":"try {\n  const launch = buildResumeLaunch(session);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('missing its Claude session ID')) {\n    console.error('This Claude session cannot be resumed; start a new session or resume manually via `claude --resume`.');\n    return;\n  }\n  throw e;\n}","preventionTips":["Keep happy-cli current so claudeSessionId is persisted at session start","Validate metadata.claudeSessionId before resuming a claude-flavored session","Do not strip fields when migrating or syncing session metadata","Filter session lists to sessions with complete metadata before offering resume"],"tags":["claude","metadata","resume","missing-field"],"backgroundTag":"missing-session-metadata","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}