{"record":{"id":"af41591e8fe423f7","repo":"apache/superset","slug":"clienterror-message-clienterror-error-t-sor","errorCode":null,"errorMessage":"clientError.message || clientError.error || t('Sorry, an error occurred')","messagePattern":"clientError\\.message \\|\\| clientError\\.error \\|\\| t\\('Sorry, an error occurred'\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"superset-frontend/src/components/Chart/chartAction.ts","lineNumber":1000,"sourceCode":"      searchParams.dashboard_id = dashboardId;\n    }\n\n    if (isDefined(perPage) && isDefined(page)) {\n      searchParams.per_page = perPage;\n      searchParams.page = page;\n    }\n\n    const response = await SupersetClient.post({\n      endpoint: '/datasource/samples',\n      jsonPayload,\n      searchParams,\n      parseMethod: 'json-bigint',\n    });\n\n    return response.json.result;\n  } catch (err) {\n    const clientError = await getClientErrorObject(err);\n    throw new Error(\n      clientError.message || clientError.error || t('Sorry, an error occurred'),\n      { cause: err },\n    );\n  }\n};\n","sourceCodeStart":982,"sourceCodeEnd":1006,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset-frontend/src/components/Chart/chartAction.ts#L982-L1006","documentation":"Thrown by getDatasourceSamples' catch block in chartAction.ts when the POST to /datasource/samples fails. getClientErrorObject extracts the server's message/error field from the failed response; if neither exists, the generic 'Sorry, an error occurred' text is used, with the original error attached as cause. The thrown message is therefore whatever the backend reported.","triggerScenarios":"Requesting sample rows for a dataset and the endpoint failing — invalid datasource id/type, database unreachable, permission denied on the database/dataset, or SQL error while the backend executed the sample query.","commonSituations":"Dataset points at a dropped/moved database; credentials rotated on the source database; Gamma user without datasource access; very wide tables timing out during sampling.","solutions":["Read err.cause and the network response for the backend's specific message — this error is a wrapper, the root cause is attached.","Verify the database connection works (Settings > Database > Test Connection) and the dataset still resolves.","Check the requesting user's access to the datasource; log in as Admin to distinguish permissions from connectivity.","If sampling times out, sample a narrower table or fix the source-database performance issue."],"exampleFix":"// before\nconst samples = await getDatasourceSamples(...);\n\n// after\ntry {\n  const samples = await getDatasourceSamples(...);\n} catch (e) {\n  notify({ message: e instanceof Error ? e.message : 'sample fetch failed' });\n  console.error('sample error cause:', (e as Error).cause);\n}","handlingStrategy":"try-catch","validationCode":"// Verify datasource is reachable before sampling:\nconst { json } = await SupersetClient.get({ endpoint: `/api/v1/dataset/${id}` });\nif (!json?.result?.database?.id) throw new Error('dataset database missing');","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await getDatasourceSamples(...);\n} catch (e) {\n  const reason = (e as Error)?.cause instanceof Error ? (e as Error).cause : e;\n  notify({ message: (e as Error).message });\n  logger.error('datasource samples failed', reason);\n}","preventionTips":["Always read err.cause — the wrapper hides the server detail","Test database connectivity from Superset when sampling suddenly fails"],"tags":["network","datasource","samples","error-wrapping"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}