{"record":{"id":"cd74057786483525","repo":"marmelab/react-admin","slug":"useupdatemany-mutation-requires-a-non-empty-data-o","errorCode":null,"errorMessage":"useUpdateMany mutation requires a non-empty data object","messagePattern":"useUpdateMany mutation requires a non-empty data object","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/dataProvider/useUpdateMany.ts","lineNumber":110,"sourceCode":"        ...mutationOptions\n    } = options;\n\n    const dataProviderUpdateMany = useEvent(\n        (resource: string, params: UpdateManyParams<RecordType>) =>\n            dataProvider.updateMany<RecordType>(resource, params)\n    );\n    const customMutationFnWithDataProviderResult = async (\n        resource: string | undefined,\n        params: Omit<UseUpdateManyMutateParams<RecordType>, 'resource'>\n    ) => {\n        if (resource == null) {\n            throw new Error('useUpdateMany mutation requires a resource');\n        }\n        if (params.ids == null) {\n            throw new Error('useUpdateMany mutation requires an array of ids');\n        }\n        if (!params.data) {\n            throw new Error(\n                'useUpdateMany mutation requires a non-empty data object'\n            );\n        }\n        if (customMutationFn == null) {\n            return dataProviderUpdateMany(\n                resource,\n                params as UpdateManyParams<RecordType>\n            );\n        }\n\n        return {\n            data: await customMutationFn({ resource, ...params }),\n        };\n    };\n\n    const [mutate, mutationResult] = useMutationWithMutationMode<\n        MutationError,\n        UpdateManyResult<RecordType>,","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/dataProvider/useUpdateMany.ts#L92-L128","documentation":"useUpdateMany requires params.data to be a truthy, non-empty object since there is nothing to update otherwise. The hook throws synchronously when data is falsy (undefined, null, empty object is truthy so undefined/null are the usual culprits).","triggerScenarios":"Calling mutate({ ids, data: undefined }) or data built conditionally (e.g. from an empty form values object that was never set).","commonSituations":"Bulk edit dialogs where the form submit passes uninitialized values; refactored code where data was moved into another variable; passing only ids and forgetting data entirely.","solutions":["Ensure a non-empty data object is passed: mutate({ ids, data: { field: value } }).","Guard the call with if (data && Object.keys(data).length > 0).","If the intent is to update one field, hardcode the payload rather than deriving it from possibly-empty state.","Check that form defaultValues are set so submitted values are never undefined."],"exampleFix":"// before\nmutate({ ids, data: updates }); // updates undefined when form untouched\n// after\nconst updates = { status: 'archived', ...formValues };\nif (ids.length && Object.keys(updates).length) {\n    mutate({ ids, data: updates });\n}","handlingStrategy":"validation","validationCode":"const canUpdate = ids.length > 0 && data != null && Object.keys(data).length > 0;\nif (canUpdate) mutate({ ids, data });","typeGuard":"const hasData = (p: { data?: unknown }): p is { data: Record<string, unknown> } =>\n    p.data != null && typeof p.data === 'object';","tryCatchPattern":"try {\n    mutate({ ids, data });\n} catch (e) {\n    if (e instanceof Error && e.message.includes('non-empty data object')) {\n        notify('No changes to apply', { type: 'warning' });\n    }\n}","preventionTips":["Never derive data solely from possibly-uninitialized form state.","Provide defaultValues in bulk-edit forms.","Assert the payload object has keys before mutating.","Log the payload in development before calling mutate."],"tags":["react-admin","mutation","validation","developer-error"],"backgroundTag":"missing-required-argument","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}