{"record":{"id":"abdb024ff023cb8d","repo":"apache/dolphinscheduler","slug":"the-workflowdefinition-should-not-be-null","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/BackfillWorkflowDTOValidator.java","lineNumber":62,"sourceCode":"    }\n\n    @Override\n    public void validate(final BackfillWorkflowDTO backfillWorkflowDTO) {\n        final BackfillWorkflowDTO.BackfillParamsDTO backfillParams = backfillWorkflowDTO.getBackfillParams();\n        if (backfillParams == null) {\n            throw new IllegalArgumentException(\"backfillParams is null\");\n        }\n        if (CollectionUtils.isEmpty(backfillParams.getBackfillDateList())) {\n            throw new IllegalArgumentException(\"backfillDateList is empty\");\n        }\n        if (backfillParams.getExpectedParallelismNumber() < 0) {\n            throw new IllegalArgumentException(\"expectedParallelismNumber should >= 0\");\n        }\n        if (backfillWorkflowDTO.getExecType() != CommandType.COMPLEMENT_DATA) {\n            throw new IllegalArgumentException(\"The execType should be START_PROCESS\");\n        }\n        if (backfillWorkflowDTO.getWorkflowDefinition() == null) {\n            throw new IllegalArgumentException(\"The workflowDefinition should not be null\");\n        }\n        if (backfillWorkflowDTO.getWorkflowDefinition().getReleaseState() != ReleaseState.ONLINE) {\n            throw new IllegalStateException(\"The workflowDefinition should be online\");\n        }\n\n        tenantExistValidator.validate(backfillWorkflowDTO.getTenantCode());\n\n        startParamListValidator.validate(backfillWorkflowDTO.getStartParamList());\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/workflow/BackfillWorkflowDTOValidator.java#L44-L73","documentation":"BackfillWorkflowDTOValidator.validate requires workflowDefinition on the DTO to be non-null, since backfill operates on a concrete workflow definition. If backfillWorkflowDTO.getWorkflowDefinition() is null, it throws IllegalArgumentException('The workflowDefinition should not be null').","triggerScenarios":"A backfill request where the server-side lookup/assembly step failed to attach the WorkflowDefinition (e.g. unknown workflow name/code) or the caller built the DTO manually without the definition.","commonSituations":"Referencing a workflow that does not exist or was deleted so the enrichment step leaves the field null; calling an internal API directly in scripts/tests without loading the definition first; race where the workflow is dropped between listing and backfilling.","solutions":["Confirm the target workflow exists (correct code/name) and was fetched before building the request.","Set workflowDefinition explicitly when constructing BackfillWorkflowDTO programmatically.","Check upstream code that populates the DTO (controller/service layer) for failed lookups being ignored.","Re-fetch the workflow list to ensure it was not deleted concurrently."],"exampleFix":"// before\nBackfillWorkflowDTO dto = new BackfillWorkflowDTO();\n// workflowDefinition never attached\n// after\ndto.setWorkflowDefinition(workflowDefinitionService.findWorkflowDefinitionByCode(code));","handlingStrategy":"validation","validationCode":"if (!dto.workflowDefinition) {\n  throw new Error('workflowDefinition must be loaded before backfilling');\n}","typeGuard":"function hasDefinition(dto) {\n  return dto?.workflowDefinition != null && typeof dto.workflowDefinition === 'object';\n}","tryCatchPattern":"try {\n  backfill(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":["Always fetch the definition via the API before building the DTO.","Handle failed lookups loudly instead of leaving the field null.","Verify workflow code/name against a fresh list call.","Don't call internal endpoints from scripts without the enrichment step."],"tags":["backfill","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-14T00:17:10.932Z"}