{"record":{"id":"a567c2b3ccc7b9fe","repo":"elsa-workflows/elsa-core","slug":"workflow-definition-with-id-definitionid-not-found","errorCode":null,"errorMessage":"Workflow definition with ID '{definitionId}' not found","messagePattern":"Workflow definition with ID '(.+?)' not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Alterations/Services/DefaultAlterationPlanScheduler.cs","lineNumber":45,"sourceCode":"    public DefaultAlterationPlanScheduler(IWorkflowDefinitionService workflowDefinitionService, IWorkflowDispatcher workflowDispatcher, IIdentityGenerator identityGenerator, IJsonSerializer jsonSerializer)\n    {\n        _workflowDefinitionService = workflowDefinitionService;\n        _workflowDispatcher = workflowDispatcher;\n        _identityGenerator = identityGenerator;\n        _jsonSerializer = jsonSerializer;\n    }\n\n    /// <inheritdoc />\n    public async Task<string> SubmitAsync(AlterationPlanParams planParams, CancellationToken cancellationToken = default)\n    {\n        if(string.IsNullOrWhiteSpace(planParams.Id))\n            planParams.Id = _identityGenerator.GenerateId();\n        \n        var definitionId = ExecuteAlterationPlanWorkflow.WorkflowDefinitionId;\n        var workflowGraph = await _workflowDefinitionService.FindWorkflowGraphAsync(definitionId, VersionOptions.Published, cancellationToken);\n        \n        if (workflowGraph == null)\n            throw new($\"Workflow definition with ID '{definitionId}' not found\");\n        \n        var serializedPlan = _jsonSerializer.Serialize(planParams);\n        var request = new DispatchWorkflowDefinitionRequest(workflowGraph.Workflow.Identity.Id)\n        {\n            Input = new Dictionary<string, object>\n            {\n                [\"Plan\"] = serializedPlan\n            }\n        };\n        await _workflowDispatcher.DispatchAsync(request, cancellationToken);\n\n        return planParams.Id;\n    }\n}","sourceCodeStart":27,"sourceCodeEnd":59,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Alterations/Services/DefaultAlterationPlanScheduler.cs#L27-L59","documentation":"The alterations (error-correction) feature dispatches an 'ExecuteAlterationPlan' workflow by its well-known definition ID. Before dispatching a submitted alteration plan, DefaultAlterationPlanScheduler resolves the published workflow graph for that definition and throws when none exists. This means the alterations infrastructure workflow is absent or not published in the target store.","triggerScenarios":"Calling IAlterationPlanScheduler.SubmitAsync (e.g. via the alterations API endpoints) when FindWorkflowGraphAsync(ExecuteAlterationPlanWorkflow.WorkflowDefinitionId, VersionOptions.Published) returns null.","commonSituations":"Fresh database that never had the alterations workflow registered/published; the alterations feature/module not installed in the app; the workflow was unpublished or deleted; querying a store (tenant/database) different from where definitions were published.","solutions":["Ensure the Elsa.Alterations module and its features are registered so ExecuteAlterationPlanWorkflow is registered and published","Publish the ExecuteAlterationPlan workflow definition in the target database","Verify you are pointed at the correct database/tenant containing the published definition","Check VersionOptions.Published is satisfied (a draft-only version is not enough)"],"exampleFix":"// before\nservices.AddElsa(elsa => elsa.AddActivities<Elsa.Alterations.Activities>()); // alterations workflow features missing\n// after\nservices.AddElsa(elsa => elsa.AddAlterations().AddActivitiesFrom<Elsa.Alterations.Activities>()); // registers & publishes plan workflow","handlingStrategy":"validation","validationCode":"var graph = await workflowDefinitionService.FindWorkflowGraphAsync(\n    ExecuteAlterationWorkflow.WorkflowDefinitionId, VersionOptions.Published, ct);\nif (graph == null)\n    throw new InvalidOperationException(\"ExecuteAlterationPlan workflow is not published in this environment\");","typeGuard":"bool CanSubmitAlterations(IWorkflowDefinitionService svc, CancellationToken ct) => svc.FindWorkflowGraphAsync(ExecuteAlterationPlanWorkflow.WorkflowDefinitionId, VersionOptions.Published, ct).GetAwaiter().GetResult() is not null;","tryCatchPattern":"try\n{\n    await scheduler.SubmitAsync(planParams, cancellationToken);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"not found\") && ex.Message.Contains(\"Workflow definition\"))\n{\n    logger.LogWarning(\"Alterations plan workflow missing; run feature registration/publish step first.\");\n}","preventionTips":["Register and publish the alterations workflow in every environment's startup","Run smoke checks that the required system workflows are published after migrations","Verify connection strings/tenants before dispatching alteration plans","Never delete or unpublish Elsa system workflows"],"tags":["alterations","workflow-definition","published-version","resource-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}