medusajs/medusa · warning

The 'forms' property is malformed. The 'forms' property must

Error message

The 'forms' property is malformed. The 'forms' property must be an array of objects.

What it means

This is the getFormsArgument check: when a 'forms' property exists on the plugin/config call but its value is not an array expression, the plugin warns that forms must be an array of objects and returns null so no configs are generated for the file.

Source

Thrown at packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-forms.ts:700

  path: NodePath<ExportDefaultDeclaration>,
  file: string
): ArrayExpression | null {
  const configArgument = getConfigArgument(path)

  if (!configArgument) {
    return null
  }

  const formProperty = configArgument.properties.find(
    (p) => isObjectProperty(p) && isIdentifier(p.key, { name: "forms" })
  ) as ObjectProperty | undefined

  if (!formProperty) {
    return null
  }

  if (!isArrayExpression(formProperty.value)) {
    logger.warn(
      `The 'forms' property is malformed. The 'forms' property must be an array of objects.`,
      { file }
    )
    return null
  }

  return formProperty.value
}

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Wrap entries in an array: forms: [{ zone: 'general', fields: { ... } }]
  2. Inline the array literal rather than computing it
  3. Verify every element is an object literal

Example fix

// before
forms: { zone: 'general', fields: { ... } }
// after
forms: [{ zone: 'general', fields: { ... } }]
Defensive patterns

Strategy: type-guard

Validate before calling

if (!Array.isArray(config.forms)) {
  throw new Error('forms must be an array of form entry objects')
}

Type guard

const isFormsArray = (v: unknown): v is unknown[] => Array.isArray(v)

Prevention

When it happens

Trigger: forms: { zone: 'general', ... } (single object instead of array), forms: getForms(), or forms: someConstant.

Common situations: Wrapping a single form in an object because there is only one, or assigning a computed/imported value.

Understand the failure class

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/586fe895d8945f21. Report an issue: GitHub.