davila7/claude-code-templates · error

Failed to load tasks

Error message

Failed to load tasks

What it means

Catch-all HTTP 500 for the tasks route: session resolved but session.tasks was undefined (accessing .length threw) or serialization failed.

Source

Thrown at cli-tool/src/teams-dashboard.js:745

          count: session.communications.length
        });
      } catch (error) {
        res.status(500).json({ error: 'Failed to load communications' });
      }
    });

    // Tasks
    this.app.get('/api/sessions/:id/tasks', async (req, res) => {
      try {
        const session = await this.parseFullSession(req.params.id);
        if (!session) return res.status(404).json({ error: 'Session not found' });

        res.json({
          tasks: session.tasks,
          count: session.tasks.length
        });
      } catch (error) {
        res.status(500).json({ error: 'Failed to load tasks' });
      }
    });

    // Single teammate detail
    this.app.get('/api/sessions/:id/teammates/:agentId', async (req, res) => {
      try {
        const session = await this.parseFullSession(req.params.id);
        if (!session) return res.status(404).json({ error: 'Session not found' });

        const agent = session.agents[req.params.agentId];
        if (!agent) return res.status(404).json({ error: 'Agent not found' });

        // Get agent-specific events
        const agentEvents = session.events
          .filter(e => e.agentId === req.params.agentId)
          .slice(0, 100);

        res.json({

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Default the field: (session.tasks || [])
  2. Re-parse via restart; remove corrupt session files if needed

Example fix

// before
tasks: session.tasks,
count: session.tasks.length
// after
tasks: session.tasks || [],
count: (session.tasks || []).length
Defensive patterns

Strategy: fallback

Validate before calling

const detail = await fetch(`/api/sessions/${id}`).then(r => r.json());
if (!Array.isArray(detail.tasks)) useEmptyTasks();

Type guard

const hasTasks = (s) => Array.isArray(s?.tasks);

Try / catch

try { tasks = await getTasks(id); } catch { tasks = { tasks: [], count: 0 }; }

Prevention

When it happens

Trigger: GET /api/sessions/:id/tasks where the parser produced a session without a tasks array (session format without task tool usage).

Common situations: Older sessions predating task tracking; empty or partially parsed logs.

Related errors


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