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

  1. Verify ~/.claude exists and is readable by the process user
  2. Check the console output 'Error getting Claude session info:' for the root cause
  3. Run the CLI once normally so Claude Code materializes its config/session files
  4. 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

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


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/6456a0f4ad075d0a. Report an issue: GitHub.