{"record":{"id":"e1be5a06f4b4eb2d","repo":"marmelab/react-admin","slug":"found-getmanyreference-result-in-cache-without-tot","errorCode":null,"errorMessage":"Found getManyReference result in cache without total or pageInfo","messagePattern":"Found getManyReference result in cache without total or pageInfo","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/dataProvider/useDeleteMany.ts","lineNumber":244,"sourceCode":"                        if (!recordWasFound) {\n                            return res;\n                        }\n                        if (res.total) {\n                            return {\n                                ...res,\n                                data: newCollection,\n                                total:\n                                    res.total -\n                                    (res.data.length - newCollection.length),\n                            };\n                        }\n                        if (res.pageInfo) {\n                            return {\n                                ...res,\n                                data: newCollection,\n                            };\n                        }\n                        throw new Error(\n                            'Found getManyReference result in cache without total or pageInfo'\n                        );\n                    },\n                    { updatedAt }\n                );\n\n                return params.ids;\n            },\n            getQueryKeys: ({ resource }) => {\n                const queryKeys = [\n                    [resource, 'getList'],\n                    [resource, 'getInfiniteList'],\n                    [resource, 'getMany'],\n                    [resource, 'getManyReference'],\n                ];\n                return queryKeys;\n            },\n            onSettled: (...args) => {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/dataProvider/useDeleteMany.ts#L226-L262","documentation":"After a delete, useDeleteMany updates the cached getManyReference result (the list of related records). The optimistic cache update needs to know the collection size, which it derives from either total (offset pagination) or pageInfo (cursor pagination). If neither field exists in the cached result, react-admin refuses to update it and throws.","triggerScenarios":"A custom data provider returns getManyReference data without total and without pageInfo; the cache was populated by a non-standard query that shaped the result differently; calling useDeleteMany inside a ReferenceManyField-like list whose provider omits pagination metadata.","commonSituations":"Custom or third-party data providers that return only { data } from getManyReference; migrating a provider built for an older react-admin contract; mocking providers in tests that forget total/pageInfo.","solutions":["Make the data provider's getManyReference return { data, total } (or { data, pageInfo } for cursor pagination).","Ensure the list query that populates the cache is fetched through useGetManyReference so the cache shape matches.","If using a mock provider in tests, include total: data.length in getManyReference responses."],"exampleFix":"// before\ngetManyReference: (resource, params) =>\n  Promise.resolve({ data: filtered });\n// after\ngetManyReference: (resource, params) =>\n  Promise.resolve({ data: filtered, total: filtered.length });","handlingStrategy":"validation","validationCode":"const res = await dataProvider.getManyReference(resource, params);\nif (res.total == null && res.pageInfo == null) {\n  throw new Error('getManyReference must return total or pageInfo');\n}","typeGuard":"const hasListMeta = (r: { total?: number; pageInfo?: unknown }): r is { total: number } | { pageInfo: object } =>\n  r.total != null || r.pageInfo != null;","tryCatchPattern":"try {\n  await mutate(resource, { ids });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('total or pageInfo')) {\n    invalidateCache(); // refetch list without optimistic update\n  } else throw e;\n}","preventionTips":["Always include total (or pageInfo) in getManyReference responses.","Test custom data providers against react-admin's provider contract.","Keep mocks in tests shape-compatible with real responses."],"tags":["react-admin","cache","dataprovider","pagination"],"backgroundTag":"invalid-dataprovider-response","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}