{"record":{"id":"592319348fb8791a","repo":"apache/dolphinscheduler","slug":"k8s-task-params-is-not-valid","errorCode":null,"errorMessage":"K8S task params is not valid","messagePattern":"K8S task params is not valid","errorType":"validation","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-k8s/src/main/java/org/apache/dolphinscheduler/plugin/task/k8s/K8sTask.java","lineNumber":69,"sourceCode":"\n    private final TaskExecutionContext taskExecutionContext;\n\n    private K8sTaskParameters k8sTaskParameters;\n\n    private K8sTaskExecutionContext k8sTaskExecutionContext;\n\n    private K8sConnectionParam k8sConnectionParam;\n    public K8sTask(TaskExecutionContext taskRequest) {\n        super(taskRequest);\n        this.taskExecutionContext = taskRequest;\n    }\n\n    @Override\n    public void init() {\n        String taskParams = taskExecutionContext.getTaskParams();\n        k8sTaskParameters = JSONUtils.parseObject(taskParams, K8sTaskParameters.class);\n        if (k8sTaskParameters == null || !k8sTaskParameters.checkParameters()) {\n            throw new TaskException(\"K8S task params is not valid\");\n        }\n\n        k8sTaskExecutionContext =\n                k8sTaskParameters.generateK8sTaskExecutionContext(taskExecutionContext.getResourceParametersHelper(),\n                        k8sTaskParameters.getDatasource());\n        k8sConnectionParam =\n                (K8sConnectionParam) DataSourceUtils.buildConnectionParams(DbType.valueOf(k8sTaskParameters.getType()),\n                        k8sTaskExecutionContext.getConnectionParams());\n        String kubeConfig = k8sConnectionParam.getKubeConfig();\n        k8sTaskParameters.setNamespace(k8sConnectionParam.getNamespace());\n        k8sTaskParameters.setKubeConfig(kubeConfig);\n        k8sTaskExecutionContext.setConfigYaml(kubeConfig);\n        k8sTaskExecutionContext.setNamespace(k8sConnectionParam.getNamespace());\n        taskRequest.setK8sTaskExecutionContext(k8sTaskExecutionContext);\n        log.info(\"Initialize k8s task params:{}\", JSONUtils.toPrettyJsonString(k8sTaskParameters));\n    }\n\n    @Override","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-k8s/src/main/java/org/apache/dolphinscheduler/plugin/task/k8s/K8sTask.java#L51-L87","documentation":"K8sTask.init() parses taskExecutionContext.getTaskParams() into K8sTaskParameters and throws TaskException 'K8S task params is not valid' when parsing yields null or checkParameters() fails. Validation happens before any Kubernetes client call, so the workflow instance fails at task startup.","triggerScenarios":"init() is called with taskParams JSON that either cannot be parsed into K8sTaskParameters (null result) or fails k8sTaskParameters.checkParameters() — missing required fields like image, namespace, or command per the check implementation.","commonSituations":"Hand-edited or legacy taskParams JSON missing newly required fields, UI saving an incomplete K8s form, params corrupted by workflow import/export, or type mismatches after plugin version upgrade (renamed/removed fields).","solutions":["Log/print taskExecutionContext.getTaskParams() and compare against K8sTaskParameters fields to find the missing/invalid one.","Re-open the K8s task in the UI and complete all required fields (image, namespace, command/args), then re-save.","Check K8sTaskParameters.checkParameters() to see the exact validation rules.","If params come from an imported workflow, re-create the task node natively.","Verify plugin and UI versions match (no schema drift between versions)."],"exampleFix":"// before (task params)\n{\"image\":\"nginx\",\"command\":null}\n// after\n{\"image\":\"nginx:1.25\",\"namespace\":\"default\",\"command\":\"echo\",\"args\":[\"hi\"]}","handlingStrategy":"validation","validationCode":"K8sTaskParameters p = JSONUtils.parseObject(taskParamsJson, K8sTaskParameters.class);\nif (p == null || !p.checkParameters()) {\n    throw new IllegalArgumentException(\"invalid K8S task params: \" + taskParamsJson);\n}","typeGuard":"static boolean hasValidK8sParams(String taskParamsJson) {\n    K8sTaskParameters p = JSONUtils.parseObject(taskParamsJson, K8sTaskParameters.class);\n    return p != null && p.checkParameters();\n}","tryCatchPattern":"try {\n    k8sTask.init();\n} catch (TaskException e) {\n    if (e.getMessage().contains(\"params is not valid\")) {\n        log.error(\"K8S task params failed validation; re-check task definition fields\", e);\n    }\n    throw e;\n}","preventionTips":["Complete all required fields (image, namespace, command) in the K8s task form before saving.","Validate taskParams JSON against K8sTaskParameters after any manual edit or workflow import.","Keep UI and plugin versions aligned to avoid schema drift.","Add a CI check that parses stored workflow params with the parameter classes."],"tags":["k8s","parameter-validation","task-config","dolphinscheduler"],"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"}