medusajs/medusa · warning
'defaultValue' property is missing at the ${j} index of the
Error message
'defaultValue' property is missing at the ${j} index of the 'forms' property in ${file}. What it means
Field configs (unlike form components) require a 'defaultValue' property so the admin can initialize the field. When a field object inside 'fields' lacks defaultValue, the plugin warns with the entry index and file, then skips that entry.
Source
Thrown at packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-forms.ts:628
) {
logger.warn(
`'${name}' property in the 'fields' property at the ${j} index of the 'forms' property in ${file} is malformed. The property must be an object or a call to form.define().`,
{ file }
)
return
}
const fieldObject = isObjectExpression(field.value)
? field.value
: (field.value.arguments[0] as ObjectExpression)
const defaultValueProperty = fieldObject.properties.find(
(p) =>
isObjectProperty(p) && isIdentifier(p.key, { name: "defaultValue" })
) as ObjectProperty | undefined
if (!defaultValueProperty) {
logger.warn(
`'defaultValue' property is missing at the ${j} index of the 'forms' property in ${file}.`,
{ file }
)
return
}
const validationProperty = fieldObject.properties.find(
(p) =>
isObjectProperty(p) && isIdentifier(p.key, { name: "validation" })
) as ObjectProperty | undefined
if (!validationProperty) {
logger.warn(
`'validation' property is missing at the ${j} index of the 'forms' property in ${file}.`,
{ file }
)
return
}View on GitHub (pinned to 5e06e544a2)
Solutions
- Add defaultValue to the field object, e.g. defaultValue: '' or defaultValue: null
- Give every field in 'fields' both defaultValue and validation
- Use form.define({ defaultValue, validation }) for clarity
Example fix
// before
fields: { myField: { validation: (v) => v.length > 2 } }
// after
fields: { myField: { defaultValue: '', validation: (v) => v.length > 2 } } Defensive patterns
Strategy: validation
Validate before calling
Object.entries(f.fields).forEach(([name, def]) => {
if (typeof def !== 'object' || !('defaultValue' in def)) {
throw new Error(`field '${name}' is missing defaultValue`)
}
}) Type guard
const hasDefaultValue = (d: unknown): d is { defaultValue: unknown } =>
typeof d === 'object' && d !== null && 'defaultValue' in (d as object) Prevention
- Always write defaultValue and validation together for every field config
When it happens
Trigger: fields: { myField: { validation: ... } } where the object has validation but no defaultValue key.
Common situations: Assuming defaultValue is optional, porting form.define component configs (which don't need it) into the config flow, or forgetting the key when hand-writing configs.
Related errors
- 'zone' property is missing from the ${j} index of the 'forms
- 'tab' property at the ${j} index of the 'forms' property is
- 'zone' and 'tab' properties at the ${j} index of the 'forms'
- The 'fields' property is missing at the ${j} index of the 'f
- The 'fields' property at the ${j} index of the 'forms' prope
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/4eddaf5fcc954cf1.
Report an issue: GitHub.