{"record":{"id":"dd957e016b985f71","repo":"apache/dolphinscheduler","slug":"joined-failure-messages-e-g-failed-do-action-e","errorCode":null,"errorMessage":"{joined failure messages, e.g. Failed do action <executeType> on workflowInstance: <id>reason: <error>}","messagePattern":"\\{joined failure messages, e\\.g\\. Failed do action <executeType> on workflowInstance: <id>reason: <error>\\}","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java","lineNumber":356,"sourceCode":"    public Result<Void> batchControlWorkflowInstance(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,\n                                                     @RequestParam(\"workflowInstanceIds\") String workflowInstanceIds,\n                                                     @RequestParam(\"executeType\") ExecuteType executeType) {\n\n        String[] workflowInstanceIdArray = workflowInstanceIds.split(Constants.COMMA);\n        List<String> errorMessage = new ArrayList<>();\n        for (String strWorkflowInstanceId : workflowInstanceIdArray) {\n            int workflowInstanceId = Integer.parseInt(strWorkflowInstanceId);\n            try {\n                execService.controlWorkflowInstance(loginUser, workflowInstanceId, executeType);\n                log.info(\"Success do action {} on workflowInstance: {}\", executeType, workflowInstanceId);\n            } catch (Exception e) {\n                errorMessage.add(\"Failed do action \" + executeType + \" on workflowInstance: \" + workflowInstanceId\n                        + \"reason: \" + e.getMessage());\n                log.error(\"Failed do action {} on workflowInstance: {}, error: {}\", executeType, workflowInstanceId, e);\n            }\n        }\n        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(errorMessage)) {\n            throw new ServiceException(String.join(\"\\n\", errorMessage));\n        }\n        return Result.success();\n    }\n\n    /**\n     * execute task instance\n     *\n     * @param loginUser      login user\n     * @param projectCode    project code\n     * @param code           taskDefinitionCode\n     * @param version        taskDefinitionVersion\n     * @param warningGroupId warning group id\n     * @param workerGroup    worker group\n     * @return start task result code\n     */\n    @Operation(summary = \"startTaskInstance\", description = \"RUN_TASK_INSTANCE_NOTES\")\n    @Parameters({\n            @Parameter(name = \"version\", description = \"VERSION\", schema = @Schema(implementation = int.class, example = \"1\")),","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java#L338-L374","documentation":"ExecutorController.batchControlWorkflowInstance applies an action (executeType) to each workflow instance in the batch, collecting per-instance errors. If any instance failed, it joins all 'Failed do action <executeType> on workflowInstance: <id>reason: <error>' lines with newlines and throws a single ServiceException. This is an aggregate failure message, not one specific cause.","triggerScenarios":"Batch endpoints (e.g. /executor/batch-instance-execute) where at least one target workflow instance cannot be controlled — instance already finished, instance not found, state does not permit the action, or permission denied — producing at least one entry in errorMessage.","commonSituations":"Batch-stopping instances that already completed between selection and execution; operating on instances belonging to another project/user; stale UI lists referencing deleted instances.","solutions":["Read the per-line reasons in the thrown message to see which instance IDs failed and why, then retry only the failed ones.","Before batching, verify each instance is in a state that allows the action (e.g. only RUNNING instances can be stopped).","Reduce batch size and inspect/refresh the instance list so IDs are current and visible to the calling user."],"exampleFix":"// before: blind batch\nexecClient.batchStop(allInstanceIds);\n// after: filter to controllable instances first\nList<Integer> stoppable = ids.stream().filter(id -> stateOf(id) == RUNNING).collect(toList());\nexecClient.batchStop(stoppable);","handlingStrategy":"try-catch","validationCode":"List<Integer> eligible = instanceIds.stream()\n    .filter(id -> {\n        WorkflowInstance wi = find(id);\n        return wi != null && wi.getState().isRunning() && canWrite(wi.getProjectCode());\n    }).collect(toList());","typeGuard":null,"tryCatchPattern":"try {\n    executorController.batchControlWorkflowInstance(...);\n} catch (ServiceException e) {\n    Set<Integer> failed = Arrays.stream(e.getMessage().split(\"\\n\"))\n        .map(l -> l.replaceAll(\".*workflowInstance: (\\\\d+).*\", \"$1\"))\n        .map(Integer::valueOf)\n        .collect(toSet());\n    log.warn(\"Retrying batch without failed ids: {}\", failed);\n}","preventionTips":["Refresh instance state immediately before batch actions.","Batch only instances visible in the target project and controllable by the user.","Parse the aggregated message to isolate failed instance IDs instead of retrying the whole batch."],"tags":["rest-api","batch-operation","workflow-instance","partial-failure"],"backgroundTag":"api-error-response","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"}