{"record":{"id":"09be089b526b33da","repo":"davila7/claude-code-templates","slug":"failed-to-fetch-analytics","errorCode":null,"errorMessage":"Failed to fetch analytics","messagePattern":"Failed to fetch analytics","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"cli-tool/src/chats-mobile.js","lineNumber":792,"sourceCode":"            totalSkills: componentsUsed.skills.length\n          },\n\n          // Optimization tips\n          optimizationTips: optimizationTips,\n\n          // Metadata\n          conversationId: conversationId,\n          project: conversation.project || 'Unknown',\n          timestamp: new Date().toISOString()\n        };\n\n        res.json({\n          success: true,\n          analytics: analytics\n        });\n      } catch (error) {\n        console.error('Error fetching conversation analytics:', error);\n        res.status(500).json({\n          error: 'Failed to fetch analytics',\n          message: error.message\n        });\n      }\n    });\n\n    // Serve the mobile chats page as default\n    this.app.get('/', (req, res) => {\n      res.sendFile(path.join(__dirname, 'analytics-web', 'chats_mobile.html'));\n    });\n\n    // Fallback for any other routes (but not for API or static files)\n    this.app.get('*', (req, res) => {\n      // Don't redirect API calls or static files\n      if (req.path.startsWith('/api/') || \n          req.path.startsWith('/services/') || \n          req.path.startsWith('/components/') || \n          req.path.startsWith('/assets/')) {","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/chats-mobile.js#L774-L810","documentation":"HTTP 500 wrapper thrown by the catch block of GET /api/conversations/:id/analytics when parsing or analyzing the conversation file fails downstream (e.g. conversationAnalyzer.getParsedConversation on the file path). The original error message is echoed in the response body's message field.","triggerScenarios":"The conversation id matched, but this.conversationAnalyzer.getParsedConversation(conversation.filePath) throws — missing/unreadable JSONL file, malformed message lines, or a changed Claude Code export format the parser doesn't understand.","commonSituations":"Conversation file deleted or moved after the index was built; a partially-written or corrupted JSONL file from a crashed session; newer Claude Code message schema breaking the analyzer; permissions issues reading ~/.claude/projects.","solutions":["Read the server console output — 'Error fetching conversation analytics:' logs the underlying error.message which pinpoints the cause","Confirm conversation.filePath exists and is readable (ls + cat a few lines of the JSONL)","If the file is truncated/corrupted, remove it or rescan so the in-memory index drops the stale entry","Update the chats-mobile package if the analyzer is behind the current Claude Code conversation format"],"exampleFix":"// before\nconst r = await fetch(`/api/conversations/${id}/analytics`);\nconst data = await r.json(); // { error: 'Failed to fetch analytics' }\n// after\nconst r = await fetch(`/api/conversations/${encodeURIComponent(id)}/analytics`);\nif (!r.ok) {\n  const { message } = await r.json();\n  console.error('analytics failed:', message); // underlying cause\n}","handlingStrategy":"try-catch","validationCode":"const convs = await (await fetch('/api/conversations')).json();\nconst conv = convs.conversations.find(c => c.id === id);\nif (conv && !fs.existsSync(conv.filePath)) alert('Conversation file missing on disk');","typeGuard":null,"tryCatchPattern":"const r = await fetch(url); if (!r.ok) { const { message } = await r.json(); /* message holds the root cause */ showRetryable(message); }","preventionTips":["Surface response.message — it wraps the underlying analyzer error","Keep the analyzer version in sync with the Claude Code export format","Don't delete conversation files while the dashboard is running"],"tags":["http-500","express","analytics","file-parsing"],"backgroundTag":"internal-server-error","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}