{"record":{"id":"2ccfb32163f3f66b","repo":"apache/dolphinscheduler","slug":"the-workflowdefinition-should-not-be-null-2ccfb3","errorCode":null,"errorMessage":"The workflowDefinition should not be null","messagePattern":"The workflowDefinition should not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/workflow/TriggerWorkflowDTOValidator.java","lineNumber":50,"sourceCode":"public class TriggerWorkflowDTOValidator implements IValidator<TriggerWorkflowDTO> {\n\n    private final TenantExistValidator tenantExistValidator;\n\n    private final StartParamListValidator startParamListValidator;\n\n    public TriggerWorkflowDTOValidator(TenantExistValidator tenantExistValidator,\n                                       StartParamListValidator startParamListValidator) {\n        this.tenantExistValidator = tenantExistValidator;\n        this.startParamListValidator = startParamListValidator;\n    }\n\n    @Override\n    public void validate(final TriggerWorkflowDTO triggerWorkflowDTO) {\n        if (triggerWorkflowDTO.getExecType() != CommandType.START_PROCESS) {\n            throw new IllegalArgumentException(\"The execType should be START_PROCESS\");\n        }\n        if (triggerWorkflowDTO.getWorkflowDefinition() == null) {\n            throw new IllegalArgumentException(\"The workflowDefinition should not be null\");\n        }\n        if (triggerWorkflowDTO.getWorkflowDefinition().getReleaseState() != ReleaseState.ONLINE) {\n            throw new IllegalStateException(\"The workflowDefinition should be online\");\n        }\n\n        tenantExistValidator.validate(triggerWorkflowDTO.getTenantCode());\n\n        startParamListValidator.validate(triggerWorkflowDTO.getStartParamList());\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/workflow/TriggerWorkflowDTOValidator.java#L32-L61","documentation":"TriggerWorkflowDTOValidator.validate requires the workflowDefinition on the trigger DTO to be non-null. A null definition means the request does not reference a concrete workflow to run, so the validator throws IllegalArgumentException('The workflowDefinition should not be null').","triggerScenarios":"Triggering a workflow where the DTO's workflowDefinition was never populated — e.g. the workflow code/name in the request matched nothing and the assembly step left the field null, or the DTO was hand-built without the definition.","commonSituations":"Triggering a deleted or nonexistent workflow; typo in workflow name/code so lookup fails silently; scripts calling internal APIs without fetching the definition; race condition where the workflow was deleted between selection and trigger.","solutions":["Verify the workflow code/name exists and pass a correctly fetched WorkflowDefinition into the DTO.","Check the controller/service code that populates workflowDefinition for ignored failed lookups.","Re-fetch the workflow list to confirm it was not deleted concurrently.","Set workflowDefinition explicitly when constructing TriggerWorkflowDTO programmatically."],"exampleFix":"// before\nTriggerWorkflowDTO dto = new TriggerWorkflowDTO();\ndto.setExecType(CommandType.START_PROCESS); // definition never set\n// after\ndto.setWorkflowDefinition(workflowDefinitionService.findWorkflowDefinitionByCode(code));","handlingStrategy":"validation","validationCode":"if (!dto.workflowDefinition) {\n  throw new Error('workflowDefinition must be loaded before triggering');\n}","typeGuard":"function hasDefinition(dto) {\n  return dto?.workflowDefinition != null && typeof dto.workflowDefinition === 'object';\n}","tryCatchPattern":"try {\n  trigger(dto);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"workflowDefinition should not be null\")) {\n    // re-fetch definition by code and retry\n  }\n}","preventionTips":["Resolve the workflow by code and verify the lookup succeeded before triggering.","Guard against triggering deleted workflows with a fresh existence check.","Avoid hand-building DTOs in scripts; use service-layer helpers that load the definition.","Log the workflow code alongside trigger failures for fast diagnosis."],"tags":["trigger","null-check","workflow-definition"],"backgroundTag":"missing-required-argument","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}