marmelab/react-admin · error · Error
ra.notification.data_provider_error
ra.notification.data_provider_error
Error message
ra.notification.data_provider_error
What it means
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.
Source
Thrown at packages/ra-core/src/dataProvider/validateResponseFormat.ts:11
import {
fetchActionsWithRecordResponse,
fetchActionsWithArrayOfIdentifiedRecordsResponse,
fetchActionsWithArrayOfRecordsResponse,
fetchActionsWithTotalResponse,
} from './dataFetchActions';
function validateResponseFormat(response, type, logger = console.error) {
if (!response) {
logger(`The dataProvider returned an empty response for '${type}'.`);
throw new Error('ra.notification.data_provider_error');
}
if (!response.hasOwnProperty('data')) {
logger(
`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}'.`
);
throw new Error('ra.notification.data_provider_error');
}
if (
fetchActionsWithArrayOfRecordsResponse.includes(type) &&
!Array.isArray(response.data)
) {
logger(
`The response to '${type}' must be like { data : [...] }, but the received data is not an array. The dataProvider is probably wrong for '${type}'`
);
throw new Error('ra.notification.data_provider_error');
}
if (
fetchActionsWithArrayOfIdentifiedRecordsResponse.includes(type) &&View on GitHub (pinned to 051f511bb0)
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.
Example fix
// before
const dataProvider = {
getList: (resource, params) => { fetch(url).then(r => r.json()); }, // no return
};
// after
const dataProvider = {
getList: (resource, params) => fetch(url).then(r => r.json()).then(json => ({ data: json, total: json.length })),
}; Defensive patterns
Strategy: type-guard
Validate before calling
const result = await myDataProvider.getList('posts', params);
if (!result || typeof result !== 'object') throw new Error('dataProvider returned empty response'); Type guard
const isValidResponse = (r: unknown): r is { data: unknown } =>
r != null && typeof r === 'object' && 'data' in r; Try / catch
try {
await dataProvider.getList('posts', params);
} catch (e) {
if (e.message === 'ra.notification.data_provider_error') {
console.error('dataProvider returned an empty response — check every verb has a return');
}
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: Hand-written dataProviders where a switch statement branch lacks a return; providers that fire-and-forget fetch calls; interceptors/middleware that swallow the response.
Related errors
- Found getManyReference result in cache without total or page
- Missing dataProvider prop. React-admin requires a valid data
- useCanAccess must be used inside a <Resource> component or p
- useCreateController requires a non-empty resource prop or co
- useEditController requires a non-empty resource prop or cont
AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30).
Data as JSON: /api/errors/078eb68a68a2ef6a.
Report an issue: GitHub.