{"record":{"id":"fd4a4685d1d6af78","repo":"apache/dolphinscheduler","slug":"emr-task-params-is-not-valid","errorCode":null,"errorMessage":"emr task params is not valid","messagePattern":"emr task params is not valid","errorType":"validation","errorClass":"EmrTaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/AbstractEmrTask.java","lineNumber":84,"sourceCode":"            .setPropertyNamingStrategy(new PropertyNamingStrategy.UpperCamelCaseStrategy());\n\n    /**\n     * constructor\n     *\n     * @param taskExecutionContext taskExecutionContext\n     */\n    protected AbstractEmrTask(TaskExecutionContext taskExecutionContext) {\n        super(taskExecutionContext);\n        this.taskExecutionContext = taskExecutionContext;\n    }\n\n    @Override\n    public void init() {\n        final String taskParams = taskExecutionContext.getTaskParams();\n        emrParameters = JSONUtils.parseObject(taskParams, EmrParameters.class);\n        log.info(\"Initialize emr task params:{}\", JSONUtils.toPrettyJsonString(taskParams));\n        if (emrParameters == null || !emrParameters.checkParameters()) {\n            throw new EmrTaskException(\"emr task params is not valid\");\n        }\n        emrClient = createEmrClient();\n    }\n\n    @Override\n    public AbstractParameters getParameters() {\n        return emrParameters;\n    }\n\n    protected AmazonElasticMapReduce createEmrClient() {\n        Map<String, String> awsProperties = PropertyUtils.getByPrefix(\"aws.emr.\", \"\");\n        return AmazonElasticMapReduceClientFactory.createAmazonElasticMapReduceClient(awsProperties);\n    }\n}\n","sourceCodeStart":66,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/AbstractEmrTask.java#L66-L99","documentation":"AbstractEmrTask.init parses taskParams into EmrParameters and validates them via checkParameters(). If parsing yields null or validation fails, it throws EmrTaskException 'emr task params is not valid' before any AWS call is made — the task definition itself is incomplete.","triggerScenarios":"JSONUtils.parseObject returns null (taskParams blank or not valid JSON), or EmrParameters.checkParameters() returns false because required fields are missing — for EmrAddStepsTask: steps/clusterId absent; for EmrJobDriverTask/EmrClusterTask: their required fields (releaseLabel, jobFlowId, etc.) absent.","commonSituations":"Task created via older UI/plugin version before a new required field existed (version skew); user left 'steps' or cluster ID empty; hand-edited task JSON dropped a mandatory property; wrong task type mapping deserializes params into EmrParameters incorrectly.","solutions":["Open the task definition JSON and confirm required EmrParameters fields are present (clusterId, steps for add-steps tasks)","Re-save the task in the UI so the plugin generates a complete params object","Upgrade/align worker plugin version with the API/UI version to avoid schema skew","Log the raw taskParams (init already logs it) and diff against a known-good definition"],"exampleFix":"// before\ntaskParams = \"{\\\"localParams\\\":[]}\" // no steps, no clusterId\n// after\ntaskParams = \"{\\\"localParams\\\":[],\\\"programType\\\":\\\"SPARK\\\",\\\"clusterId\\\":\\\"j-XXXX\\\",\\\"steps\\\":[{\\\"name\\\":\\\"step1\\\",\\\"actionOnFailure\\\":\\\"CONTINUE\\\",\\\"mainClass\\\":\\\"...\\\",\\\"jarPath\\\":\\\"s3://b/app.jar\\\"}]}\"","handlingStrategy":"validation","validationCode":"// before creating the task, verify required fields in taskParams JSON\nMap<String,Object> params = JSONUtils.parseObject(rawParams, Map.class);\nList<String> required = List.of(\"clusterId\", \"steps\"); // for EmrAddStepsTask\nfor (String k : required) {\n    if (params == null || !params.containsKey(k))\n        throw new IllegalArgumentException(\"taskParams missing required field: \" + k);\n}","typeGuard":"boolean hasValidEmrParams(String taskParams) {\n    EmrParameters p = JSONUtils.parseObject(taskParams, EmrParameters.class);\n    return p != null && p.checkParameters();\n}","tryCatchPattern":"try {\n    task.init();\n} catch (EmrTaskException e) {\n    if (e.getMessage().contains(\"emr task params is not valid\")) {\n        log.error(\"Fix task definition params; raw: {}\", taskExecutionContext.getTaskParams(), e);\n    }\n    throw e;\n}","preventionTips":["Create EMR tasks through the UI so the params schema is complete","After plugin upgrades, re-save existing EMR task definitions to pick up new required fields","Diff failing taskParams against a known-working definition","Never leave clusterId/steps blank for EMR add-steps tasks"],"tags":["aws","emr","validation","task-params"],"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-14T05:17:10.506Z"}