{"record":{"id":"8a5f6027bb68f170","repo":"apache/dolphinscheduler","slug":"data-is-null","errorCode":"DATA_IS_NULL","errorMessage":"DATA_IS_NULL: data {0} can not be null","messagePattern":"DATA_IS_NULL: data (.+?) can not be null","errorType":"validation","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java","lineNumber":185,"sourceCode":"    @Autowired\n    private TaskDatasourcePermissionChecker taskDatasourcePermissionChecker;\n\n    @Autowired\n    private TaskSubWorkflowPermissionChecker taskSubWorkflowPermissionChecker;\n\n    @Override\n    public List<WorkflowInstanceSummaryVO> queryTopNLongestRunningWorkflowInstance(User loginUser, long projectCode,\n                                                                                   int size,\n                                                                                   String startTime, String endTime) {\n        Project project = projectDao.queryByCode(projectCode);\n        // check user access for project\n        projectService.checkProjectAndAuthThrowException(loginUser, project, WORKFLOW_INSTANCE);\n\n        if (0 > size) {\n            throw new ServiceException(Status.NEGTIVE_SIZE_NUMBER_ERROR, size);\n        }\n        if (Objects.isNull(startTime)) {\n            throw new ServiceException(Status.DATA_IS_NULL, Constants.START_TIME);\n        }\n        Date start = DateUtils.stringToDate(startTime);\n        if (Objects.isNull(endTime)) {\n            throw new ServiceException(Status.DATA_IS_NULL, Constants.END_TIME);\n        }\n        Date end = DateUtils.stringToDate(endTime);\n        if (start == null || end == null) {\n            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.START_END_DATE);\n        }\n        if (start.getTime() > end.getTime()) {\n            throw new ServiceException(Status.START_TIME_BIGGER_THAN_END_TIME_ERROR, startTime, endTime);\n        }\n\n        return workflowInstanceDao.queryTopNWorkflowInstance(size, start, end, WorkflowExecutionStatus.SUCCESS,\n                projectCode)\n                .stream()\n                .map(WorkflowInstanceSummaryVO::fromSummaryDto)\n                .collect(Collectors.toList());","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java#L167-L203","documentation":"The queryTopNLongestRunningWorkflowInstance API validates its time parameters before querying workflow instance statistics. When the startTime request parameter is null, it throws ServiceException with Status.DATA_IS_NULL and the message template 'data {0} can not be null' where {0} is substituted with 'startTime'. This guards the subsequent DateUtils.stringToDate conversion from a null input.","triggerScenarios":"Calling GET /projects/{projectName}/workflow-instances/top-N (queryTopNLongestRunningWorkflowInstance) while omitting the startTime query parameter or passing it as an empty/absent value.","commonSituations":"Frontend clients building the statistics page forget the startTime query param; API consumers scripting against the endpoint omit optional-looking time fields; Swagger/Postman calls executed with default parameter sets that leave startTime blank.","solutions":["Pass a valid startTime query parameter in 'yyyy-MM-dd HH:mm:ss' format (e.g. 2024-01-01 00:00:00).","Fix the frontend/scheduler caller so it always sends both startTime and endTime for the top-N query.","If calling the service programmatically, check Objects.isNull(startTime) before invoking the method."],"exampleFix":"// before\ngithubApi.queryTopNLongestRunningWorkflowInstance(loginUser, project, size, null, endTime);\n// after\nString startTime = \"2024-01-01 00:00:00\";\ngithubApi.queryTopNLongestRunningWorkflowInstance(loginUser, project, size, startTime, endTime);","handlingStrategy":"validation","validationCode":"// client-side pre-check\nif (startTime == null || startTime.isEmpty()) {\n    throw new IllegalArgumentException(\"startTime is required (format: yyyy-MM-dd HH:mm:ss)\");\n}","typeGuard":"function hasStartTime(p: { startTime?: string }): p is { startTime: string } {\n  return typeof p.startTime === 'string' && p.startTime.length > 0;\n}","tryCatchPattern":"try {\n    // top-N query\n} catch (ServiceException e) {\n    if (e.getCode() == Status.DATA_IS_NULL.getCode()) {\n        // prompt user / default startTime, e.g. 7 days ago\n    } else throw e;\n}","preventionTips":["Always send both startTime and endTime for statistics endpoints","Default the time window client-side (e.g. last 7 days) instead of leaving fields blank","Validate date parameters in the frontend form before submission"],"tags":["api","validation","null-parameter","workflow-instance"],"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"}