apache/dolphinscheduler · error · TaskException

K8S task params is not valid

Error message

K8S task params is not valid

What it means

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.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-k8s/src/main/java/org/apache/dolphinscheduler/plugin/task/k8s/K8sTask.java:69

    private final TaskExecutionContext taskExecutionContext;

    private K8sTaskParameters k8sTaskParameters;

    private K8sTaskExecutionContext k8sTaskExecutionContext;

    private K8sConnectionParam k8sConnectionParam;
    public K8sTask(TaskExecutionContext taskRequest) {
        super(taskRequest);
        this.taskExecutionContext = taskRequest;
    }

    @Override
    public void init() {
        String taskParams = taskExecutionContext.getTaskParams();
        k8sTaskParameters = JSONUtils.parseObject(taskParams, K8sTaskParameters.class);
        if (k8sTaskParameters == null || !k8sTaskParameters.checkParameters()) {
            throw new TaskException("K8S task params is not valid");
        }

        k8sTaskExecutionContext =
                k8sTaskParameters.generateK8sTaskExecutionContext(taskExecutionContext.getResourceParametersHelper(),
                        k8sTaskParameters.getDatasource());
        k8sConnectionParam =
                (K8sConnectionParam) DataSourceUtils.buildConnectionParams(DbType.valueOf(k8sTaskParameters.getType()),
                        k8sTaskExecutionContext.getConnectionParams());
        String kubeConfig = k8sConnectionParam.getKubeConfig();
        k8sTaskParameters.setNamespace(k8sConnectionParam.getNamespace());
        k8sTaskParameters.setKubeConfig(kubeConfig);
        k8sTaskExecutionContext.setConfigYaml(kubeConfig);
        k8sTaskExecutionContext.setNamespace(k8sConnectionParam.getNamespace());
        taskRequest.setK8sTaskExecutionContext(k8sTaskExecutionContext);
        log.info("Initialize k8s task params:{}", JSONUtils.toPrettyJsonString(k8sTaskParameters));
    }

    @Override

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Log/print taskExecutionContext.getTaskParams() and compare against K8sTaskParameters fields to find the missing/invalid one.
  2. Re-open the K8s task in the UI and complete all required fields (image, namespace, command/args), then re-save.
  3. Check K8sTaskParameters.checkParameters() to see the exact validation rules.
  4. If params come from an imported workflow, re-create the task node natively.
  5. Verify plugin and UI versions match (no schema drift between versions).

Example fix

// before (task params)
{"image":"nginx","command":null}
// after
{"image":"nginx:1.25","namespace":"default","command":"echo","args":["hi"]}
Defensive patterns

Strategy: validation

Validate before calling

K8sTaskParameters p = JSONUtils.parseObject(taskParamsJson, K8sTaskParameters.class);
if (p == null || !p.checkParameters()) {
    throw new IllegalArgumentException("invalid K8S task params: " + taskParamsJson);
}

Type guard

static boolean hasValidK8sParams(String taskParamsJson) {
    K8sTaskParameters p = JSONUtils.parseObject(taskParamsJson, K8sTaskParameters.class);
    return p != null && p.checkParameters();
}

Try / catch

try {
    k8sTask.init();
} catch (TaskException e) {
    if (e.getMessage().contains("params is not valid")) {
        log.error("K8S task params failed validation; re-check task definition fields", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/592319348fb8791a. Report an issue: GitHub.