{"record":{"id":"445df6490600a167","repo":"apache/dolphinscheduler","slug":"shell-task-params-is-not-valid","errorCode":null,"errorMessage":"shell task params is not valid","messagePattern":"shell task params is not valid","errorType":"validation","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java","lineNumber":56,"sourceCode":"\n    private ShellParameters shellParameters;\n\n    private final ShellCommandExecutor shellCommandExecutor;\n\n    public ShellTask(TaskExecutionContext taskExecutionContext) {\n        super(taskExecutionContext);\n\n        this.shellCommandExecutor = new ShellCommandExecutor(taskExecutionContext);\n    }\n\n    @Override\n    public void init() {\n\n        shellParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), ShellParameters.class);\n        log.info(\"Initialize shell task params {}\", JSONUtils.toPrettyJsonString(shellParameters));\n\n        if (shellParameters == null || !shellParameters.checkParameters()) {\n            throw new TaskException(\"shell task params is not valid\");\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public void handle(TaskCallBack taskCallBack) throws TaskException {\n        try {\n            IShellInterceptorBuilder<?, ?> shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()\n                    .properties(ParameterUtils.convert(taskRequest.getPrepareParamsMap()))\n                    .appendScript(shellParameters.getRawScript());\n\n            TaskResponse commandExecuteResult = shellCommandExecutor.run(shellActuatorBuilder, taskCallBack);\n            setExitStatusCode(commandExecuteResult.getExitStatusCode());\n            setProcessId(commandExecuteResult.getProcessId());\n            shellParameters.dealOutParam(shellCommandExecutor.getTaskOutputParams());\n            taskRequest.setVarPool(shellParameters.getVarPool());\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java#L38-L74","documentation":"ShellTask.init() parses the task's JSON params into ShellParameters via JSONUtils and validates them. If parsing yields null or ShellParameters.checkParameters() returns false, a TaskException is thrown with this message. checkParameters() fails when the shell script body is empty/absent, so the task has nothing to execute.","triggerScenarios":"TaskExecutionContext.getTaskParams() is null/blank, is not valid JSON, or deserializes to a ShellParameters whose localParams/rawScript field is empty so checkParameters() returns false.","commonSituations":"Workflow saved with an empty script editor box; upstream automation posted a task-def JSON missing the script field; params corrupted by double-encoding the JSON when calling the API.","solutions":["Open the task definition and enter the shell script in the Script field (rawScript must be non-empty)","Validate the task params JSON before submitting: JSONUtils.parseObject(params, ShellParameters.class) != null and checkParameters() == true","If submitting via API/Python SDK, confirm the taskParams object includes the script content and that it is serialized once, not double-encoded"],"exampleFix":"// before (API request with empty script)\n{\"taskType\":\"SHELL\",\"taskParams\":{\"localParams\":[]}}\n// after\n{\"taskType\":\"SHELL\",\"taskParams\":{\"rawScript\":\"echo hello\",\"localParams\":[]}}","handlingStrategy":"validation","validationCode":"ShellParameters p = JSONUtils.parseObject(taskRequest.getTaskParams(), ShellParameters.class);\nif (p == null || !p.checkParameters()) {\n    throw new IllegalArgumentException(\"shell task params missing or script empty\");\n}","typeGuard":"boolean isValidShellParams(String json) {\n    ShellParameters p = JSONUtils.parseObject(json, ShellParameters.class);\n    return p != null && p.checkParameters();\n}","tryCatchPattern":null,"preventionTips":["Never save a SHELL task node with an empty script editor","Assert params JSON serializes and checkParameters() passes in workflow CI tests before submitting via API","Avoid double-encoding task params JSON in SDK/API calls"],"tags":["task-params","validation","config"],"backgroundTag":"schema-validation-failed","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"}