{"record":{"id":"078eb68a68a2ef6a","repo":"marmelab/react-admin","slug":"ra-notification-data-provider-error","errorCode":"ra.notification.data_provider_error","errorMessage":"ra.notification.data_provider_error","messagePattern":"ra\\.notification\\.data_provider_error","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/dataProvider/validateResponseFormat.ts","lineNumber":11,"sourceCode":"import {\n    fetchActionsWithRecordResponse,\n    fetchActionsWithArrayOfIdentifiedRecordsResponse,\n    fetchActionsWithArrayOfRecordsResponse,\n    fetchActionsWithTotalResponse,\n} from './dataFetchActions';\n\nfunction validateResponseFormat(response, type, logger = console.error) {\n    if (!response) {\n        logger(`The dataProvider returned an empty response for '${type}'.`);\n        throw new Error('ra.notification.data_provider_error');\n    }\n    if (!response.hasOwnProperty('data')) {\n        logger(\n            `The response to '${type}' must be like { data: ... }, but the received response does not have a 'data' key. The dataProvider is probably wrong for '${type}'.`\n        );\n        throw new Error('ra.notification.data_provider_error');\n    }\n    if (\n        fetchActionsWithArrayOfRecordsResponse.includes(type) &&\n        !Array.isArray(response.data)\n    ) {\n        logger(\n            `The response to '${type}' must be like { data : [...] }, but the received data is not an array. The dataProvider is probably wrong for '${type}'`\n        );\n        throw new Error('ra.notification.data_provider_error');\n    }\n    if (\n        fetchActionsWithArrayOfIdentifiedRecordsResponse.includes(type) &&","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/dataProvider/validateResponseFormat.ts#L1-L29","documentation":"validateResponseFormat checks that a custom dataProvider returns a well-formed response. When the dataProvider returns null/undefined for a query type, react-admin logs the details to console.error and throws this generic error, which surfaces as a data_provider_error notification because the real problem is the provider's contract violation.","triggerScenarios":"A custom dataProvider method returns nothing (missing return statement) or an async function resolves to undefined; a wrapped provider forgets to return for one verb (e.g. deleteMany).","commonSituations":"Hand-written dataProviders where a switch statement branch lacks a return; providers that fire-and-forget fetch calls; interceptors/middleware that swallow the response.","solutions":["Ensure every dataProvider method returns a promise resolving to an object: return fetch(...).then(...).","Check the console — the logger prints 'The dataProvider returned an empty response for <type>' pinpointing the verb.","Add return before async calls in each case branch of the provider.","Wrap the provider with a debug proxy logging each call and its result."],"exampleFix":"// before\nconst dataProvider = {\n  getList: (resource, params) => { fetch(url).then(r => r.json()); }, // no return\n};\n// after\nconst dataProvider = {\n  getList: (resource, params) => fetch(url).then(r => r.json()).then(json => ({ data: json, total: json.length })),\n};","handlingStrategy":"type-guard","validationCode":"const result = await myDataProvider.getList('posts', params);\nif (!result || typeof result !== 'object') throw new Error('dataProvider returned empty response');","typeGuard":"const isValidResponse = (r: unknown): r is { data: unknown } =>\n    r != null && typeof r === 'object' && 'data' in r;","tryCatchPattern":"try {\n    await dataProvider.getList('posts', params);\n} catch (e) {\n    if (e.message === 'ra.notification.data_provider_error') {\n        console.error('dataProvider returned an empty response — check every verb has a return');\n    }\n}","preventionTips":["Always return the promise from every dataProvider method.","Write contract tests asserting each verb resolves to a non-null object.","Lint with no-floating-promises to catch missing returns.","Log provider calls with a wrapper during development."],"tags":["react-admin","dataprovider","contract-violation","api"],"backgroundTag":"dataprovider-invalid-response","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}