{"record":{"id":"77497cf0d72d41ec","repo":"QuantumNous/new-api","slug":"we-could-not-load-system-tasks","errorCode":null,"errorMessage":"We could not load system tasks.","messagePattern":"We could not load system tasks\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"web/src/features/system-info/components/system-tasks-panel.tsx","lineNumber":214,"sourceCode":"                  {task.error || '-'}\n                </TableCell>\n              </TableRow>\n            )\n          })}\n        </TableBody>\n      </Table>\n    </div>\n  )\n}\n\nexport function SystemTasksPanel() {\n  const { t } = useTranslation()\n  const tasksQuery = useQuery({\n    queryKey: ['system-info', 'system-tasks'],\n    queryFn: async () => {\n      const res = await listSystemTasks(TASK_LIMIT)\n      if (!res.success || !Array.isArray(res.data)) {\n        throw new Error(res.message || t('We could not load system tasks.'))\n      }\n      return res.data\n    },\n    staleTime: 30 * 1000,\n    retry: false,\n    refetchInterval: (query) =>\n      query.state.data?.some((task) => isActiveStatus(task.status))\n        ? ACTIVE_POLL_INTERVAL_MS\n        : false,\n  })\n\n  const tasks = tasksQuery.data ?? []\n  const loading = tasksQuery.isLoading\n  const refreshing = tasksQuery.isFetching && !tasksQuery.isLoading\n  const hasActiveTasks = tasks.some((task) => isActiveStatus(task.status))\n  const activeTasks = tasks.filter((task) => isActiveStatus(task.status))\n  const historyTasks = tasks.filter((task) => !isActiveStatus(task.status))\n","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/QuantumNous/new-api/blob/e2c7aa7b102c2075eae2377df3508658d45e88dc/web/src/features/system-info/components/system-tasks-panel.tsx#L196-L232","documentation":"Thrown by the SystemTasksPanel queryFn when listSystemTasks(TASK_LIMIT) rejects or returns success=false / non-array data. With retry:false the panel immediately shows its error state with this message; polling restarts only when the query refetches.","triggerScenarios":"GET of the system-tasks list fails: non-admin caller, backend task registry error, type mismatch where data is an object (e.g. paginated envelope) rather than the expected array, or network/backend outage.","commonSituations":"Non-admin opens system info; backend version skew where the endpoint returns {data:{items:[...]}} instead of a bare array; task store (DB table) missing after a failed migration; proxy 502 during deploy.","solutions":["Verify the caller is an admin; the system-tasks endpoint is privileged.","Inspect the raw response: if data is not an array, the frontend service and backend contract have diverged — align listSystemTasks with the actual response shape.","Check backend logs/migrations for the system tasks table if the handler errors.","For transient failures, refetch manually or wait for the conditional poll to resume."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":"function isTaskList(data: unknown): data is SystemTask[] {\n  return Array.isArray(data) && data.every(\n    (t): t is SystemTask =>\n      typeof t === 'object' && t !== null && typeof (t as SystemTask).status === 'string'\n  )\n}","tryCatchPattern":"queryFn: async () => {\n  const res = await listSystemTasks(TASK_LIMIT)\n  if (!res.success || !Array.isArray(res.data)) {\n    throw new Error(res.message || t('We could not load system tasks.'))\n  }\n  return res.data\n},\nretry: false,","preventionTips":["Pin frontend and backend versions together so the tasks response envelope stays an array.","Guard the panel by admin role before mounting.","Exercise the endpoint in CI contract tests to catch schema drift before deploy."],"tags":["system-info","system-tasks","tanstack-query","api-error"],"backgroundTag":null,"analyzedSha":"e2c7aa7b102c2075eae2377df3508658d45e88dc","analyzedAt":"2026-08-15T10:35:18.111Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}