getDefaultFormState: a string or array default merged with object form data turns into index keys
Author: jimmycallinCreated Sep 30, 2026Updated Sep 30, 2026
Labelsneeds triage
mergeDefaultsWithFormData() copies the defaults with Object.assign({}, defaults) when the form data is an object, so a string or array default turns into index keys.
getDefaultFormState(validator, { type: 'string', const: 'x', default: { a: 1 } }, { b: 2 });
// { '0': 'x', b: 2 }This happens on v7 (checked with @rjsf/validator-ajv8 on 63b14f1 plus #5386). typescript/no-misused-spread, enabled in #5386, doesn't flag it because it only checks spread syntax, not Object.assign. Found by @heath-freenome in review of #5386, where it was left out of scope.
The location is packages/utils/src/mergeDefaultsWithFormData.ts, in the isObject(formData) branch.
Generated with Claude Code
Source: rjsf-team/react-jsonschema-form