Verified Production Fix
[gitlab-org/gitlab] Consolidate duplicate workflow execution services
GL-gitlab-org/gitlab#592630 • Mar 07, 2026
### ROOT CAUSE
The duplication of workflow execution services (`CreateAndStartWorkflowService` and `ExecuteWorkflowService`) stems from overlapping responsibilities and inconsistent parameter handling. This redundancy leads to confusion, maintenance overhead, and bugs, such as environment settings being overwritten.
### CODE FIX
To consolidate the duplicate services, follow these steps:
1. **Create a Consolidated Service**
- Merge the functionality of both services into a single `WorkflowExecutionService`.
- Include parameters from both services, preserving catalog-specific parameters (`json_config`, `additional_context`) while ensuring environment settings respect workflow definitions.
2. **Update Callers**
- Modify `ee/app/services/ai/duo_workflows/create_and_start_workflow_service.rb` and `ee/app/services/ai/catalog/execute_workflow_service.rb` to use the new `WorkflowExecutionService`.
- Update all dependent flows (AI Catalog, Code Review, Fix Pipeline) to use the consolidated service.
3. **Remove Duplicate Services**
- After updating callers, remove the old services to reduce redundancy.
ruby
# New consolidated service
class WorkflowExecutionService
def initialize(workflow_id, environment: nil, json_config: nil, additional_context: nil)
@workflow_id = workflow_id
@environment = environment
@json_config = json_config
@additional_context = additional_context
end
def execute
workflow = Workflow.find(@workflow_id)
workflow_service = workflow.create_service
workflow_service.create_workflow(
environment: @environment || workflow.environment,
json_config: @json_config,
additional_context: @additional_context
)
end
end
# Example of updating a caller
class CodeReviewService
def process_workflow(workflow_id)
WorkflowExecutionService.new(workflow_id).execute
end
end
# Remove old services
# Remove ee/app/services/ai/duo_workflows/create_and_start_workflow_service.rb
# Remove ee/app/services/ai/catalog/execute_workflow_service.rb
Deploy with Vultr
Use this fix in production instantly. Claim your high-performance developer credit.
Get Started with Vultr →
digital