{"record":{"id":"6456a0f4ad075d0a","repo":"davila7/claude-code-templates","slug":"failed-to-get-claude-session-info","errorCode":null,"errorMessage":"Failed to get Claude session info","messagePattern":"Failed to get Claude session info","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"cli-tool/src/analytics.js","lineNumber":1135,"sourceCode":"      res.json({\n        version: packageJson.version,\n        name: packageJson.name,\n        description: packageJson.description,\n        timestamp: Date.now()\n      });\n    });\n\n    // Claude session information endpoint\n    this.app.get('/api/claude/session', async (req, res) => {\n      try {\n        const sessionInfo = await this.getClaudeSessionInfo();\n        res.json({\n          ...sessionInfo,\n          timestamp: Date.now()\n        });\n      } catch (error) {\n        console.error('Error getting Claude session info:', error);\n        res.status(500).json({ \n          error: 'Failed to get Claude session info',\n          timestamp: Date.now()\n        });\n      }\n    });\n\n    // Performance metrics endpoint\n    this.app.get('/api/system/metrics', (req, res) => {\n      try {\n        const timeframe = parseInt(req.query.timeframe) || 300000; // 5 minutes default\n        const stats = this.performanceMonitor.getStats(timeframe);\n        res.json({\n          ...stats,\n          dataCache: this.dataCache.getStats(),\n          timestamp: Date.now()\n        });\n      } catch (error) {\n        res.status(500).json({","sourceCodeStart":1117,"sourceCodeEnd":1153,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/analytics.js#L1117-L1153","documentation":"500 from GET /api/session (Claude session info). The handler gathers current Claude Code session metadata (config, active projects, session files); any error during that collection is logged and replaced by this generic message.","triggerScenarios":"GET /api/session when ~/.claude config files are missing/malformed, or session-state files cannot be read (permissions, concurrent write).","commonSituations":"Fresh machine where Claude Code hasn't created config yet; permissions changed on ~/.claude; running analytics as a different user than the one using Claude Code.","solutions":["Verify ~/.claude exists and is readable by the process user","Check the console output 'Error getting Claude session info:' for the root cause","Run the CLI once normally so Claude Code materializes its config/session files","Retry after closing other processes writing to ~/.claude"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const exists = await fs.promises.access(path.join(os.homedir(), '.claude'), fs.constants.R_OK).then(() => true).catch(() => false);","typeGuard":null,"tryCatchPattern":"try { const s = await getSession(); } catch (e) { if (e.response?.status === 500) return { available: false, reason: 'session-info-unavailable' }; throw e; }","preventionTips":["Ensure ~/.claude exists and is readable","Run one normal Claude Code session before analytics","Run analytics as the same OS user as Claude Code"],"tags":["analytics","express","http-500","session"],"backgroundTag":"internal-server-error-handler","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}