{"record":{"id":"3ca86b867fdf765e","repo":"medusajs/medusa","slug":"job-registration-requires-sourcepath-received","errorCode":null,"errorMessage":"Job registration requires sourcePath. Received: ${JSON.stringify(data)}","messagePattern":"Job registration requires sourcePath\\. Received: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/utils/src/dev-server/handlers/job-handler.ts","lineNumber":14,"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      )\n    }\n  }\n\n  resolveSourcePath(data: JobResourceData): string {\n    return data.sourcePath\n  }","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/dev-server/handlers/job-handler.ts#L1-L32","documentation":"Dev-server validation error from JobHandler.validate: a job resource was registered without `sourcePath`, the filesystem path of the file that defines the job. The dev server needs the source path to watch the file and hot-reload the job when it changes, so registration is rejected.","triggerScenarios":"Registering a job with { type: 'job', id, config } but omitting sourcePath; building registration data from import.meta.url incorrectly (e.g. stripping the file URL to an empty string); plugin loaders that register jobs without forwarding the originating file path.","commonSituations":"Custom plugin setups where jobs are collected in an index and registered in a loop losing per-file paths; refactors that move registration away from the job file; path derivation that returns undefined on Windows or when bundled.","solutions":["Pass the absolute path of the job module file, typically derived with import.meta.url (fileURLToPath(import.meta.url)).","If registering from a central place, thread the originating file path through your loader into the registration call.","Verify the value is a non-empty string right before registering."],"exampleFix":"// before\nregisterDevServerResource({ type: 'job', id, config })\n\n// after\nimport { fileURLToPath } from 'node:url'\nregisterDevServerResource({\n  type: 'job',\n  id: config.name,\n  sourcePath: fileURLToPath(import.meta.url),\n  config,\n})","handlingStrategy":"validation","validationCode":"import { fileURLToPath } from 'node:url'\nconst sourcePath = fileURLToPath(import.meta.url)\nif (!sourcePath) throw new Error('sourcePath could not be derived')","typeGuard":"function hasSourcePath(d: unknown): d is { sourcePath: string } {\n  return typeof (d as any)?.sourcePath === 'string' && (d as any).sourcePath.length > 0\n}","tryCatchPattern":null,"preventionTips":["Always derive sourcePath with fileURLToPath(import.meta.url) at the registration site.","Avoid bundling registration code away from its source file.","Assert non-empty path before calling registration APIs."],"tags":["dev-server","job","source-path","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"}