{"record":{"id":"2416ec7d3452ef2e","repo":"medusajs/medusa","slug":"zone-property-is-not-a-string-or-array","errorCode":null,"errorMessage":"'zone' property is not a string or array.","messagePattern":"'zone' property is not a string or array\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/admin/admin-vite-plugin/src/widgets/generate-widgets.ts","lineNumber":338,"sourceCode":"\nfunction extractZoneValues(value: Node, zones: string[], file: string) {\n  if (isTemplateLiteral(value)) {\n    logger.warn(\n      `'zone' property cannot be a template literal (e.g. \\`product.details.after\\`).`,\n      { file }\n    )\n    return\n  }\n\n  if (isStringLiteral(value)) {\n    zones.push(value.value)\n  } else if (isArrayExpression(value)) {\n    const values = value.elements\n      .filter((e) => isStringLiteral(e))\n      .map((e) => e.value)\n    zones.push(...values)\n  } else {\n    logger.warn(`'zone' property is not a string or array.`, { file })\n    return\n  }\n}\n","sourceCodeStart":320,"sourceCodeEnd":342,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/admin/admin-vite-plugin/src/widgets/generate-widgets.ts#L320-L342","documentation":"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.","triggerScenarios":"zone: someCondition ? \"a\" : \"b\", zone: getZone(), zone: 42, or zone: { mobile: \"...\" }.","commonSituations":"Trying to compute zones dynamically or conditionally at module evaluation time.","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"],"exampleFix":"// before\nexport const config = defineWidgetConfig({\n  zone: isAdmin ? \"product.details.after\" : \"product.details.before\",\n})\n\n// after\nexport const config = defineWidgetConfig({\n  zone: [\"product.details.after\", \"product.details.before\"],\n})","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const isStaticZoneValue = (v: unknown): v is string | string[] =>\n  typeof v === \"string\" || (Array.isArray(v) && v.every(e => typeof e === \"string\"))","tryCatchPattern":null,"preventionTips":["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"],"tags":["admin","widgets","zone","static-analysis"],"backgroundTag":"build-time-static-analysis","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}