davila7/claude-code-templates · error

Failed to generate activity data

Error message

Failed to generate activity data

What it means

500 from GET /api/activity. The handler computes activity/aggregated usage data from parsed conversations; failures in reading or aggregating the Claude projects data surface as this generic message.

Source

Thrown at cli-tool/src/analytics.js:1231

        res.status(500).json({ 
          error: 'Failed to clear cache', 
          details: error.message 
        });
      }
    });

    // Activity heatmap data endpoint — uses in-memory cached conversations
    this.app.get('/api/activity', async (req, res) => {
      try {
        const conversations = this.data.conversations ?? [];
        const activityData = this.generateActivityDataFromConversations(conversations);
        res.json({
          ...activityData,
          timestamp: new Date().toISOString()
        });
      } catch (error) {
        console.error('Error generating activity data:', error);
        res.status(500).json({ error: 'Failed to generate activity data' });
      }
    });

    // Year in Review 2025 API endpoint
    this.app.get('/api/2025', async (req, res) => {
      try {
        console.log('📅 Generating 2025 Year in Review...');

        // Load all conversations for analysis
        const allConversations = await this.conversationAnalyzer.loadConversations(this.stateCalculator);

        // Generate year in review statistics
        const yearInReview = await this.yearInReview2025.generateYearInReview(allConversations, this.claudeDir);

        console.log(`✅ 2025 Year in Review generated with ${yearInReview.totalConversations} conversations`);

        res.json({
          ...yearInReview,

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Check console for 'Error generating activity data:' and the underlying stack
  2. Clear conversation caches (POST /api/clear-cache?type=conversations) and retry
  3. Scan ~/.claude/projects for 0-byte or truncated .jsonl files and remove them
  4. Re-run the analytics scan/refresh endpoint to rebuild state
Defensive patterns

Strategy: try-catch

Validate before calling

const convs = await fetch(base + '/api/conversations').then(r => r.ok); // data load sanity check

Try / catch

try { return await getActivity(); } catch (e) { if (e.response?.status === 500) { await clearConversationCaches(); return await getActivity(); } throw e; }

Prevention

When it happens

Trigger: GET /api/activity when a conversation JSONL is corrupt, a file disappears during aggregation, or an in-memory aggregation hits an unexpected shape (e.g. missing field on a conversation object).

Common situations: Dashboard open while Claude Code writes sessions; projects dir contains leftover partial files; huge dirs causing read errors.

Related errors


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