{"record":{"id":"01d2674bec53df54","repo":"medusajs/medusa","slug":"workflow-registration-requires-sourcepath-receive","errorCode":null,"errorMessage":"Workflow registration requires sourcePath. Received: ${JSON.stringify(data)}","messagePattern":"Workflow registration requires sourcePath\\. Received: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/utils/src/dev-server/handlers/workflow-handler.ts","lineNumber":12,"sourceCode":"import {\n  ResourceEntry,\n  ResourceTypeHandler,\n  WorkflowResourceData,\n} from \"../types\"\n\nexport class WorkflowHandler\n  implements ResourceTypeHandler<WorkflowResourceData>\n{\n  readonly type = \"workflow\"\n\n  validate(data: WorkflowResourceData): void {\n    if (!data.sourcePath) {\n      throw new Error(\n        `Workflow registration requires sourcePath. Received: ${JSON.stringify(\n          data\n        )}`\n      )\n    }\n\n    if (!data.id) {\n      throw new Error(\n        `Workflow registration requires id. Received: ${JSON.stringify(data)}`\n      )\n    }\n  }\n\n  resolveSourcePath(data: WorkflowResourceData): string {\n    return data.sourcePath\n  }","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/dev-server/handlers/workflow-handler.ts#L1-L30","documentation":"Dev-server validation error from WorkflowHandler.validate: a workflow resource was registered without `sourcePath`. The dev server watches the workflow's defining file to hot-reload it (and its steps) during development; without the path, registration is rejected.","triggerScenarios":"Registering a workflow with { type: 'workflow', id } but no sourcePath; loaders that register workflows from a central manifest without the file location.","commonSituations":"Custom setups enumerating workflows from configuration; bundling or path-alias setups where deriving the real file path fails; refactors moving registration away from the workflow file.","solutions":["Pass the absolute path of the workflow module file (fileURLToPath(import.meta.url) where the workflow is defined).","If registering from a manifest, store and forward each workflow's file path.","Check the derived path is non-empty before calling registration."],"exampleFix":"// before\nregisterDevServerResource({ type: 'workflow', id: 'cart-workflow' })\n\n// after\nregisterDevServerResource({\n  type: 'workflow',\n  id: 'cart-workflow',\n  sourcePath: fileURLToPath(import.meta.url),\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":["Derive sourcePath from import.meta.url inside the workflow module.","Store file paths in workflow manifests if you register centrally.","Assert the path is non-empty before registration."],"tags":["dev-server","workflow","source-path","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"}