medusajs/medusa · warning

'zone' property is not a string or array.

Error message

'zone' property is not a string or array.

What it means

extractZoneValues only accepts a string literal or an array of string literals for the `zone` property. Any other AST node type (numeric literal, object, function call, conditional expression) triggers this warning and the zone value is ignored, likely leaving the widget without zones.

Source

Thrown at packages/admin/admin-vite-plugin/src/widgets/generate-widgets.ts:338

function extractZoneValues(value: Node, zones: string[], file: string) {
  if (isTemplateLiteral(value)) {
    logger.warn(
      `'zone' property cannot be a template literal (e.g. \`product.details.after\`).`,
      { file }
    )
    return
  }

  if (isStringLiteral(value)) {
    zones.push(value.value)
  } else if (isArrayExpression(value)) {
    const values = value.elements
      .filter((e) => isStringLiteral(e))
      .map((e) => e.value)
    zones.push(...values)
  } else {
    logger.warn(`'zone' property is not a string or array.`, { file })
    return
  }
}

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Inline the final zone list as a string literal or array of string literals
  2. List all zones explicitly in an array instead of branching
  3. Restart the dev server

Example fix

// before
export const config = defineWidgetConfig({
  zone: isAdmin ? "product.details.after" : "product.details.before",
})

// after
export const config = defineWidgetConfig({
  zone: ["product.details.after", "product.details.before"],
})
Defensive patterns

Strategy: type-guard

Type guard

const isStaticZoneValue = (v: unknown): v is string | string[] =>
  typeof v === "string" || (Array.isArray(v) && v.every(e => typeof e === "string"))

Prevention

When it happens

Trigger: zone: someCondition ? "a" : "b", zone: getZone(), zone: 42, or zone: { mobile: "..." }.

Common situations: Trying to compute zones dynamically or conditionally at module evaluation time.

Related errors


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