{"record":{"id":"697fe142b42f0e10","repo":"apache/dolphinscheduler","slug":"expectedparallelismnumber-should-0","errorCode":null,"errorMessage":"expectedParallelismNumber should >= 0","messagePattern":"expectedParallelismNumber should >= 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/workflow/BackfillWorkflowDTOValidator.java","lineNumber":56,"sourceCode":"    private final StartParamListValidator startParamListValidator;\n\n    public BackfillWorkflowDTOValidator(TenantExistValidator tenantExistValidator,\n                                        StartParamListValidator startParamListValidator) {\n        this.tenantExistValidator = tenantExistValidator;\n        this.startParamListValidator = startParamListValidator;\n    }\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":38,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/workflow/BackfillWorkflowDTOValidator.java#L38-L73","documentation":"BackfillWorkflowDTOValidator.validate checks that backfillParams.expectedParallelismNumber is non-negative. A negative value would mean an invalid number of parallel complement instances, so the validator throws IllegalArgumentException('expectedParallelismNumber should >= 0').","triggerScenarios":"A backfill request whose backfillParams.expectedParallelismNumber is negative (e.g. -1), typically from a client defaulting to -1 to mean 'unset' and sending it as-is.","commonSituations":"Front-end leaving the parallelism input blank and sending -1 as a sentinel; script/SDK constructing params with an uninitialized int; copying a request example and editing parallelism down to test limits.","solutions":["Set expectedParallelismNumber to a value >= 0 (0 usually means serial/no parallelism).","Fix the client to omit/nullify the field instead of sending -1 when the user did not choose a value.","Clamp user input in the UI: max(0, parsedValue) before building the request.","Add client-side validation with a clear message before the API call."],"exampleFix":"// before\nparams.setExpectedParallelismNumber(-1); // sentinel for 'unset'\n// after\nparams.setExpectedParallelismNumber(Math.max(0, requestedParallelism));","handlingStrategy":"validation","validationCode":"if (params.expectedParallelismNumber == null || params.expectedParallelismNumber < 0) {\n  throw new Error('expectedParallelismNumber must be >= 0');\n}","typeGuard":"function hasValidParallelism(params) {\n  return Number.isInteger(params?.expectedParallelismNumber) && params.expectedParallelismNumber >= 0;\n}","tryCatchPattern":"try {\n  backfill(dto);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"expectedParallelismNumber\")) {\n    // clamp to >= 0 and retry once\n  }\n}","preventionTips":["Clamp UI number inputs with max(0, value).","Never use -1 as an 'unset' sentinel in numeric fields.","Initialize ints to 0, not defaults from uninitialized memory.","Document 0 = serial execution for API consumers."],"tags":["backfill","parallelism","validation"],"backgroundTag":"argument-out-of-range","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"}