{"record":{"id":"9e373c79074a3a79","repo":"medusajs/medusa","slug":"job-registration-requires-id-received-json-str","errorCode":null,"errorMessage":"Job registration requires id. Received: ${JSON.stringify(data)}","messagePattern":"Job registration requires id\\. Received: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/utils/src/dev-server/handlers/job-handler.ts","lineNumber":8,"sourceCode":"import { JobResourceData, ResourceEntry, ResourceTypeHandler } from \"../types\"\n\nexport class JobHandler implements ResourceTypeHandler<JobResourceData> {\n  readonly type = \"job\"\n\n  validate(data: JobResourceData): void {\n    if (!data.id) {\n      throw new Error(\n        `Job registration requires id. Received: ${JSON.stringify(data)}`\n      )\n    }\n\n    if (!data.sourcePath) {\n      throw new Error(\n        `Job registration requires sourcePath. Received: ${JSON.stringify(\n          data\n        )}`\n      )\n    }\n\n    if (!data.config?.name) {\n      throw new Error(\n        `Job registration requires config.name. Received: ${JSON.stringify(\n          data\n        )}`\n      )","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/dev-server/handlers/job-handler.ts#L1-L26","documentation":"Dev-server validation error: when registering a scheduled job resource with the Medusa development server, the resource data carried no `id`. JobHandler.validate throws before the resource is tracked, so hot-reload registration of the job is aborted.","triggerScenarios":"Calling the dev-server registration API for a job (type: 'job') with a payload missing the id field; a job file whose registration metadata is built dynamically and the id ends up undefined.","commonSituations":"Writing custom scheduled jobs in a Medusa project and the loader passes an incomplete config; renaming the id field in job config while the registration code still reads the old key; frameworks/plugins that auto-register jobs from a glob and encounter a file exporting no id.","solutions":["Ensure the job registration data includes a stable, unique id (commonly the job scheduler name).","If ids are derived from config, check for undefined before registering (data.id ?? throw).","Confirm you are registering with type 'job' and constructing JobResourceData with all required fields (id, sourcePath, config.name)."],"exampleFix":"// before\nregisterDevServerResource({ type: 'job', sourcePath, config }) // no id\n\n// after\nregisterDevServerResource({ type: 'job', id: config.name, sourcePath, config })","handlingStrategy":"validation","validationCode":"if (!data.id) throw new Error(`Missing job id in ${data.sourcePath ?? 'unknown file'}`)","typeGuard":"function isJobResourceData(d: unknown): d is JobResourceData {\n  return !!d && typeof (d as any).id === 'string' && !!(d as any).sourcePath && !!(d as any).config?.name\n}","tryCatchPattern":null,"preventionTips":["Default job id to config.name when constructing registration data.","Centralize resource-data construction in one factory that asserts required fields.","Run the dev server locally so registration errors surface at save time."],"tags":["dev-server","job","registration","validation","hot-reload"],"backgroundTag":"missing-required-field-registration","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}