davila7/claude-code-templates · error
Failed to get Claude session info
Error message
Failed to get Claude session info
What it means
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.
Source
Thrown at cli-tool/src/analytics.js:1135
res.json({
version: packageJson.version,
name: packageJson.name,
description: packageJson.description,
timestamp: Date.now()
});
});
// Claude session information endpoint
this.app.get('/api/claude/session', async (req, res) => {
try {
const sessionInfo = await this.getClaudeSessionInfo();
res.json({
...sessionInfo,
timestamp: Date.now()
});
} catch (error) {
console.error('Error getting Claude session info:', error);
res.status(500).json({
error: 'Failed to get Claude session info',
timestamp: Date.now()
});
}
});
// Performance metrics endpoint
this.app.get('/api/system/metrics', (req, res) => {
try {
const timeframe = parseInt(req.query.timeframe) || 300000; // 5 minutes default
const stats = this.performanceMonitor.getStats(timeframe);
res.json({
...stats,
dataCache: this.dataCache.getStats(),
timestamp: Date.now()
});
} catch (error) {
res.status(500).json({View on GitHub (pinned to a0851ed10c)
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
Defensive patterns
Strategy: try-catch
Validate before calling
const exists = await fs.promises.access(path.join(os.homedir(), '.claude'), fs.constants.R_OK).then(() => true).catch(() => false);
Try / catch
try { const s = await getSession(); } catch (e) { if (e.response?.status === 500) return { available: false, reason: 'session-info-unavailable' }; throw e; } Prevention
- Ensure ~/.claude exists and is readable
- Run one normal Claude Code session before analytics
- Run analytics as the same OS user as Claude Code
When it happens
Trigger: GET /api/session when ~/.claude config files are missing/malformed, or session-state files cannot be read (permissions, concurrent write).
Common situations: 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.
Related errors
- Failed to update states
- Failed to get system health
- Failed to get performance metrics
- Failed to clear cache
- Failed to generate activity data
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/6456a0f4ad075d0a.
Report an issue: GitHub.