{"record":{"id":"e0c7278c3548ee58","repo":"QuantumNous/new-api","slug":"we-could-not-load-instances","errorCode":null,"errorMessage":"We could not load instances.","messagePattern":"We could not load instances\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"web/src/features/system-info/components/system-instances-panel.tsx","lineNumber":503,"sourceCode":"          })}\n        </TableBody>\n      </Table>\n    </div>\n  )\n}\n\nexport function SystemInstancesPanel() {\n  const { t } = useTranslation()\n  const queryClient = useQueryClient()\n  const [deleteTarget, setDeleteTarget] = useState<SystemInstance | null>(null)\n  const [deleteAllConfirmOpen, setDeleteAllConfirmOpen] = useState(false)\n  const [deletingNodeName, setDeletingNodeName] = useState<string | null>(null)\n  const instancesQuery = useQuery({\n    queryKey: ['system-info', 'instances'],\n    queryFn: async () => {\n      const res = await listSystemInstances()\n      if (!res.success || !Array.isArray(res.data)) {\n        throw new Error(res.message || t('We could not load instances.'))\n      }\n      return res.data\n    },\n    staleTime: 30 * 1000,\n    retry: false,\n    refetchInterval: INSTANCE_POLL_INTERVAL_MS,\n  })\n\n  const instances = instancesQuery.data ?? []\n  const staleInstances = instances.filter(\n    (instance) => instance.status === 'stale'\n  )\n  const hasStaleInstances = staleInstances.length > 0\n  const loading = instancesQuery.isLoading\n  const refreshing = instancesQuery.isFetching && !instancesQuery.isLoading\n\n  const invalidateInstances = async () => {\n    await queryClient.invalidateQueries({","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/QuantumNous/new-api/blob/e2c7aa7b102c2075eae2377df3508658d45e88dc/web/src/features/system-info/components/system-instances-panel.tsx#L485-L521","documentation":"Thrown by the useQuery queryFn in SystemInstancesPanel when listSystemInstances() rejects or returns success=false / a non-array data field. It is the panel's load failure path; because retry:false, the query lands in error state immediately and the panel renders its error UI with this message.","triggerScenarios":"GET /api/system_instances (or equivalent) returns non-2xx or success=false: caller lacks admin rights, node stats middleware not enabled, or the endpoint errors while aggregating node heartbeats; also plain network failure or backend down.","commonSituations":"Non-admin user opens the system-info page; backend restarted and instance registry is empty; multi-node deployment where nodes have not phoned home; reverse proxy returning 502 while the Go service restarts.","solutions":["Check the HTTP status: 401/403 means the current user is not authorized for instance listing; sign in as an admin.","Inspect response.message in the network tab for the backend's specific failure (e.g. Redis unreachable).","Confirm the Go backend version actually exposes the instances endpoint used by listSystemInstances().","If it is a transient network issue, the panel's refetchInterval polling will retry automatically; otherwise reload after fixing the backend."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isInstanceList(data: unknown): data is SystemInstance[] {\n  return Array.isArray(data) && data.every(\n    (i): i is SystemInstance =>\n      typeof i === 'object' && i !== null && typeof (i as SystemInstance).status === 'string'\n  )\n}","tryCatchPattern":"queryFn: async () => {\n  const res = await listSystemInstances()\n  if (!res.success || !Array.isArray(res.data)) {\n    throw new Error(res.message || t('We could not load instances.'))\n  }\n  return res.data\n},\nretry: false,\nrefetchInterval: INSTANCE_POLL_INTERVAL_MS, // auto-recovers from transient failures","preventionTips":["Gate the panel behind an admin permission check so unauthorized users never trigger the call.","Keep retry:false but rely on refetchInterval polling for self-healing.","Type-narrow res.data before use so contract drift fails loudly in dev, not silently in prod."],"tags":["system-info","tanstack-query","api-error","admin"],"backgroundTag":null,"analyzedSha":"e2c7aa7b102c2075eae2377df3508658d45e88dc","analyzedAt":"2026-08-15T10:35:18.111Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}