{"record":{"id":"fd7648c248b0abcc","repo":"apache/superset","slug":"received-unexpected-response-status-response-st","errorCode":null,"errorMessage":"Received unexpected response status (${response.status}) while fetching chart data","messagePattern":"Received unexpected response status \\((.+?)\\) while fetching chart data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"superset-frontend/src/components/Chart/chartAction.ts","lineNumber":662,"sourceCode":"  if (isFeatureEnabled(FeatureFlag.GlobalAsyncQueries)) {\n    // deal with getChartDataRequest transforming the response data\n    const result = 'result' in json ? json.result : json;\n    switch (response.status) {\n      case 200:\n        // Query results returned synchronously, meaning query was already cached.\n        return Promise.resolve(result);\n      case 202:\n        // Query is running asynchronously and we must await the results.\n        // When status is 202, result contains async event data (job_id, channel_id, etc.)\n        // which differs from QueryData. We cast through unknown to handle this safely.\n        // The optional signal lets a caller abort the wait (Stop pressed, chart\n        // superseded or unmounted), cancelling the job and avoiding leaked listeners.\n        return waitForAsyncData(\n          result as unknown as Parameters<typeof waitForAsyncData>[0],\n          signal,\n        ) as Promise<QueryData[]>;\n      default:\n        throw new Error(\n          `Received unexpected response status (${response.status}) while fetching chart data`,\n        );\n    }\n  }\n  return json.result;\n}\n\nexport function exploreJSON(\n  formData: QueryFormData | LatestQueryFormData,\n  force = false,\n  timeout?: number,\n  key?: string | number,\n  dashboardId?: number,\n  ownState?: JsonObject,\n): ChartThunkAction<Promise<unknown[]>> {\n  return async (\n    dispatch: ChartThunkDispatch,\n    getState: () => RootState,","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset-frontend/src/components/Chart/chartAction.ts#L644-L680","documentation":"Thrown by exploreJSON's response handling in chartAction.ts when the /api/v1/chart/data (or explore_json) response status is neither 200 nor 202. Only synchronous success (200) and async-accepted (202) are modeled; any other status — 400/401/403/404/429/500/502 — reaches the default branch and is converted into this generic error, discarding the structured body.","triggerScenarios":"Any chart data fetch where the backend replies with an unexpected status: expired session (401), missing permission (403), malformed query context (400), rate limiting (429), or backend/worker crash (5xx). Also proxies/gateways that return 502/504 while Superset restarts.","commonSituations":"Session timeout on a long-open dashboard tab; gateway misrouting in containerized deployments; backend OOM during a heavy query; API changes between frontend and backend versions during a partial deploy.","solutions":["Reproduce with the same payload and inspect the response body/network tab — the status in the message tells you which layer failed (auth, validation, backend).","401/403: re-login and verify the user's roles/collection access; 429: back off; 5xx: check Superset/gunicorn logs for the underlying exception.","Ensure frontend and backend versions match after deploys (no stale bundle talking to a new API).","In calling code, catch this error and fall back to showing the chart error state instead of retrying blindly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// No pre-flight validation possible for an arbitrary HTTP status; verify auth/session first:\nawait SupersetClient.get({ endpoint: '/health' });","typeGuard":null,"tryCatchPattern":"try {\n  await exploreJSON(formData);\n} catch (e) {\n  const m = /unexpected response status \\((\\d+)\\)/.exec(String(e?.message));\n  if (m?.[1] === '401') redirectToLogin();\n  else if (m?.[1] === '429') scheduleRetry(backoffMs);\n  else showChartError(e);\n}","preventionTips":["Keep sessions alive / handle 401 globally","Match frontend and backend versions during deploys","Surface status codes in monitoring to catch gateway issues"],"tags":["network","http-status","chart-data","api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}