{"record":{"id":"a2d8bc10a93b7b04","repo":"davila7/claude-code-templates","slug":"failed-to-load-tasks","errorCode":null,"errorMessage":"Failed to load tasks","messagePattern":"Failed to load tasks","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"cli-tool/src/teams-dashboard.js","lineNumber":745,"sourceCode":"          count: session.communications.length\n        });\n      } catch (error) {\n        res.status(500).json({ error: 'Failed to load communications' });\n      }\n    });\n\n    // Tasks\n    this.app.get('/api/sessions/:id/tasks', async (req, res) => {\n      try {\n        const session = await this.parseFullSession(req.params.id);\n        if (!session) return res.status(404).json({ error: 'Session not found' });\n\n        res.json({\n          tasks: session.tasks,\n          count: session.tasks.length\n        });\n      } catch (error) {\n        res.status(500).json({ error: 'Failed to load tasks' });\n      }\n    });\n\n    // Single teammate detail\n    this.app.get('/api/sessions/:id/teammates/:agentId', async (req, res) => {\n      try {\n        const session = await this.parseFullSession(req.params.id);\n        if (!session) return res.status(404).json({ error: 'Session not found' });\n\n        const agent = session.agents[req.params.agentId];\n        if (!agent) return res.status(404).json({ error: 'Agent not found' });\n\n        // Get agent-specific events\n        const agentEvents = session.events\n          .filter(e => e.agentId === req.params.agentId)\n          .slice(0, 100);\n\n        res.json({","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/teams-dashboard.js#L727-L763","documentation":"Catch-all HTTP 500 for the tasks route: session resolved but session.tasks was undefined (accessing .length threw) or serialization failed.","triggerScenarios":"GET /api/sessions/:id/tasks where the parser produced a session without a tasks array (session format without task tool usage).","commonSituations":"Older sessions predating task tracking; empty or partially parsed logs.","solutions":["Default the field: (session.tasks || [])","Re-parse via restart; remove corrupt session files if needed"],"exampleFix":"// before\ntasks: session.tasks,\ncount: session.tasks.length\n// after\ntasks: session.tasks || [],\ncount: (session.tasks || []).length","handlingStrategy":"fallback","validationCode":"const detail = await fetch(`/api/sessions/${id}`).then(r => r.json());\nif (!Array.isArray(detail.tasks)) useEmptyTasks();","typeGuard":"const hasTasks = (s) => Array.isArray(s?.tasks);","tryCatchPattern":"try { tasks = await getTasks(id); } catch { tasks = { tasks: [], count: 0 }; }","preventionTips":["Expect sessions without task data (older formats)"],"tags":["http-500","teams-dashboard","express"],"backgroundTag":"http-500-internal-server-error","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}