{"record":{"id":"46ecffbd61105e46","repo":"medusajs/medusa","slug":"subscriber-registration-requires-events-received","errorCode":null,"errorMessage":"Subscriber registration requires events. Received: ${JSON.stringify(data)}","messagePattern":"Subscriber registration requires events\\. Received: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/utils/src/dev-server/handlers/subscriber-handler.ts","lineNumber":34,"sourceCode":"      )\n    }\n\n    if (!data.sourcePath) {\n      throw new Error(\n        `Subscriber registration requires sourcePath. Received: ${JSON.stringify(\n          data\n        )}`\n      )\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 {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/dev-server/handlers/subscriber-handler.ts#L16-L52","documentation":"Dev-server validation error from SubscriberHandler.validate: a subscriber resource was registered without an `events` field. The dev server needs the list of event names the subscriber listens to in order to wire tracking; a registration without events is rejected.","triggerScenarios":"Registering a subscriber with { type: 'subscriber', id, sourcePath, subscriberId } and no events; building registration data from a subscriber config that omits the events array (e.g. a handler-based subscriber where events are implied).","commonSituations":"Subscribers whose event list is derived from the class (EVENT handers) rather than declared in config, while the loader still expects an explicit array; refactors dropping the field; plugin metadata missing the events key.","solutions":["Add the events array listing every event name the subscriber handles, e.g. ['order.placed', 'order.canceled'].","If events are inferred from the subscriber implementation, compute the list and pass it explicitly at registration time.","Verify event names are strings and spelled exactly as emitted by the event bus."],"exampleFix":"// before\nregisterDevServerResource({ type: 'subscriber', id, sourcePath, subscriberId })\n\n// after\nregisterDevServerResource({\n  type: 'subscriber', id, sourcePath, subscriberId,\n  events: ['order.placed'],\n})","handlingStrategy":"validation","validationCode":"if (!data.events) throw new Error(`Subscriber ${data.id} must declare events`)","typeGuard":"function hasEvents(d: unknown): d is { events: unknown[] } {\n  return Array.isArray((d as any)?.events) && (d as any).events.length > 0\n}","tryCatchPattern":null,"preventionTips":["Declare the event list explicitly even when the implementation implies it.","Reuse constants for event names to avoid typos drifting between emitter and subscriber.","Validate the full registration object in one guard before calling the dev server."],"tags":["dev-server","subscriber","events","registration","validation"],"backgroundTag":"missing-required-field-registration","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}