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
- Inline the final zone list as a string literal or array of string literals
- List all zones explicitly in an array instead of branching
- 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
- Inline the full zone list; avoid ternaries, function calls, or objects in zone
- Remember the plugin does static AST analysis — runtime cleverness will not work
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
- 'zone' property is missing from the widget config.
- 'zone' property is not a valid injection zone.
- 'zone' property cannot be a template literal (e.g. `product.
- 'model' property cannot be a template literal (e.g. `product
- 'model' is invalid. The 'model' property must be a string li
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/2416ec7d3452ef2e.
Report an issue: GitHub.