{"record":{"id":"e93efd0e1756f87a","repo":"medusajs/medusa","slug":"subscriber-registration-requires-events-to-be-an-a","errorCode":null,"errorMessage":"Subscriber registration requires events to be an array. Received: ${JSON.stringify(data)}","messagePattern":"Subscriber registration requires events to be an array\\. Received: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/utils/src/dev-server/handlers/subscriber-handler.ts","lineNumber":42,"sourceCode":"      )\n    }\n\n    if (!data.subscriberId) {\n      throw new Error(\n        `Subscriber registration requires subscriberId. Received: ${JSON.stringify(\n          data\n        )}`\n      )\n    }\n\n    if (!data.events) {\n      throw new Error(\n        `Subscriber registration requires events. Received: ${JSON.stringify(\n          data\n        )}`\n      )\n    }\n\n    if (!Array.isArray(data.events)) {\n      throw new Error(\n        `Subscriber registration requires events to be an array. Received: ${JSON.stringify(\n          data\n        )}`\n      )\n    }\n  }\n\n  resolveSourcePath(data: SubscriberResourceData): string {\n    return data.sourcePath\n  }\n\n  createEntry(data: SubscriberResourceData): ResourceEntry {\n    return {\n      id: data.id,\n      subscriberId: data.subscriberId,\n      events: data.events,","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/dev-server/handlers/subscriber-handler.ts#L24-L60","documentation":"Dev-server validation error from SubscriberHandler.validate: the `events` field was provided but is not an Array (Array.isArray(data.events) is false). Subscribers must declare the event names they listen to as an array, so a string, object, or other non-array value is rejected.","triggerScenarios":"Registering a subscriber with events: 'order.placed' (a single string) instead of an array; events set to an object map like { 'order.placed': handler }; events set to a comma-joined string built by string concatenation.","commonSituations":"Loosely-typed config objects from JSON/YAML where a single event is written as a scalar; JS code paths where the type is never checked before registration.","solutions":["Wrap single events in an array: events: ['order.placed'].","If your config accepts a scalar or list, normalize before registering: Array.isArray(events) ? events : [events].","Type the registration payload (SubscriberResourceData) so TypeScript rejects non-array events at compile time."],"exampleFix":"// before\nregisterDevServerResource({ type: 'subscriber', id, sourcePath, subscriberId, events: 'order.placed' })\n\n// after\nregisterDevServerResource({ type: 'subscriber', id, sourcePath, subscriberId, events: ['order.placed'] })","handlingStrategy":"type-guard","validationCode":"const events = Array.isArray(config.events) ? config.events : [config.events].filter(Boolean)","typeGuard":"function isEventArray(events: unknown): events is string[] {\n  return Array.isArray(events) && events.every((e) => typeof e === 'string')\n}","tryCatchPattern":null,"preventionTips":["Always declare events as an array, even for a single event.","Normalize config-sourced values (JSON/YAML) before registration.","Type the field as string[] in your own config types."],"tags":["dev-server","subscriber","events","type-validation","registration"],"backgroundTag":"wrong-field-type-registration","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}