{"record":{"id":"131a44ce04b23fe3","repo":"apache/dolphinscheduler","slug":"request-params-not-valid-error-131a44","errorCode":"REQUEST_PARAMS_NOT_VALID_ERROR","errorMessage":"REQUEST_PARAMS_NOT_VALID_ERROR: request parameter {0} is not valid","messagePattern":"REQUEST_PARAMS_NOT_VALID_ERROR: request parameter (.+?) is not valid","errorType":"validation","errorClass":"ServiceException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":1141,"sourceCode":"        // nodes that are running\n        Map<Long, List<TreeViewDto>> runningNodeMap = new ConcurrentHashMap<>();\n\n        // nodes that are waiting to run\n        Map<Long, List<TreeViewDto>> waitingRunningNodeMap = new ConcurrentHashMap<>();\n\n        // List of workflow instances\n        List<WorkflowInstanceSummaryDto> workflowInstanceList =\n                workflowInstanceService.queryByWorkflowDefinitionCode(code, limit);\n        workflowInstanceList.forEach(workflowInstance -> workflowInstance\n                .setDuration(\n                        DateUtils.format2Duration(workflowInstance.getStartTime(), workflowInstance.getEndTime())));\n        List<TaskDefinitionLog> taskDefinitionList = taskDefinitionLogDao.queryByWorkflowDefinitionCodeAndVersion(\n                workflowDefinition.getCode(), workflowDefinition.getVersion());\n        Map<Long, TaskDefinitionLog> taskDefinitionMap = taskDefinitionList.stream()\n                .collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog));\n\n        if (limit < 0) {\n            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR);\n        }\n        if (limit > workflowInstanceList.size()) {\n            limit = workflowInstanceList.size();\n        }\n\n        TreeViewDto parentTreeViewDto = new TreeViewDto();\n        parentTreeViewDto.setName(\"DAG\");\n        parentTreeViewDto.setType(\"\");\n        parentTreeViewDto.setCode(0L);\n        // Specify the workflow definition, because it is a TreeView for a workflow definition\n        for (int i = limit - 1; i >= 0; i--) {\n            WorkflowInstanceSummaryDto workflowInstance = workflowInstanceList.get(i);\n            Date endTime = workflowInstance.getEndTime() == null ? new Date() : workflowInstance.getEndTime();\n            parentTreeViewDto.getInstances()\n                    .add(new Instance(workflowInstance.getId(), workflowInstance.getName(),\n                            workflowInstance.getWorkflowDefinitionCode(),\n                            \"\", workflowInstance.getState().name(), workflowInstance.getStartTime(), endTime,\n                            workflowInstance.getHost(),","sourceCodeStart":1123,"sourceCodeEnd":1159,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L1123-L1159","documentation":"Thrown by viewTree when the requested 'limit' (number of workflow instances to render in the tree) is negative. Only non-negative limits are accepted; the limit is clamped to the instance count afterwards.","triggerScenarios":"GET .../view-tree?limit=-1 (or any negative value) — the query parameter is parsed as an int and fails the limit < 0 check.","commonSituations":"Client-side code computing limit from a delta that went negative; copy-paste of a URL with a negative query param; UI bug sending -1 as 'unlimited'; automated scripts iterating limits incorrectly.","solutions":["Pass a non-negative limit (e.g. limit >= 0); use a positive number to cap rendered instances.","Clamp the limit client-side: limit = Math.max(0, limit) before calling the API.","Omit or set a sensible default (e.g. 10) instead of a sentinel negative value.","If a UI/plugin computes the limit, fix its formula so it cannot go negative."],"exampleFix":"// before\nGET .../view-tree?limit=-1\n// after\nGET .../view-tree?limit=10","handlingStrategy":"validation","validationCode":"if (limit < 0) throw new IllegalArgumentException(\"limit must be >= 0\");\nString url = base + \"/view-tree?limit=\" + Math.max(0, limit);","typeGuard":null,"tryCatchPattern":"try {\n    tree = client.viewTree(projectCode, code, limit);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode()) {\n        tree = client.viewTree(projectCode, code, Math.max(0, limit));\n    } else throw e;\n}","preventionTips":["Clamp/sanitize the limit query parameter before building the request","Use a positive default (e.g. 10) instead of negative sentinels for 'all'","Test URL-building code paths for sign errors"],"tags":["query-parameter","validation","tree-view"],"backgroundTag":"invalid-query-parameter","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"}