apache/dolphinscheduler · error · RuntimeException

flink task params is not valid

Error message

flink task params is not valid

What it means

FlinkStreamTask.init() deserializes the taskParams JSON into FlinkStreamParameters and validates them via checkParameters(). If the JSON cannot be parsed or required fields (e.g. main jar / program type) are missing, it throws RuntimeException('flink task params is not valid'). It guards against executing a Flink streaming job with an unusable configuration.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-flink-stream/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkStreamTask.java:53

public class FlinkStreamTask extends FlinkTask implements StreamTask {

    private FlinkStreamParameters flinkParameters;

    private final TaskExecutionContext taskExecutionContext;

    public FlinkStreamTask(TaskExecutionContext taskExecutionContext) {
        super(taskExecutionContext);
        this.taskExecutionContext = taskExecutionContext;
    }

    @Override
    public void init() {

        flinkParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), FlinkStreamParameters.class);
        log.info("Initialize Flink task params {}", JSONUtils.toPrettyJsonString(flinkParameters));

        if (flinkParameters == null || !flinkParameters.checkParameters()) {
            throw new RuntimeException("flink task params is not valid");
        }
    }

    @Override
    protected String getScript() {
        return buildScriptWithParameterReplacement(flinkParameters);
    }

    @Override
    public AbstractParameters getParameters() {
        return flinkParameters;
    }

    @Override
    public void cancelApplication() throws TaskException {
        List<String> appIds = getApplicationIds();
        if (CollectionUtils.isEmpty(appIds)) {
            log.error("can not get appId, taskInstanceId:{}", taskExecutionContext.getTaskInstanceId());

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Inspect the taskParams JSON of the failing task instance and confirm it parses as FlinkStreamParameters
  2. Fill in required fields (mainJar resource, mainClass, programType) in the Flink task form and save
  3. Re-run the task after re-saving so taskParams are regenerated
  4. If caused by an upgrade, re-create or migrate the task definition to the current schema

Example fix

// before
{"localParams":[],"resourceList":[]}
// after
{"mainClass":"com.example.Main","programType":"SQL","resourceList":[{"resourceName":"job.jar"}],"localParams":[]}
Defensive patterns

Strategy: validation

Validate before calling

FlinkStreamParameters params = JSONUtils.parseObject(taskParams, FlinkStreamParameters.class);
if (params == null || !params.checkParameters()) {
    throw new IllegalArgumentException("taskParams must deserialize to FlinkStreamParameters and pass checkParameters()");
}

Type guard

boolean isValidParams(String json) {
    FlinkStreamParameters p = JSONUtils.parseObject(json, FlinkStreamParameters.class);
    return p != null && p.checkParameters();
}

Try / catch

try {
    task.init();
} catch (RuntimeException e) {
    log.error("Flink task params invalid: {}", taskExecutionContext.getTaskParams(), e);
    // mark task failed, do not retry blindly
}

Prevention

When it happens

Trigger: taskExecutionContext.getTaskParams() is null, malformed JSON, or deserializes to a FlinkStreamParameters whose checkParameters() returns false (missing mainJar/mainClass/programType depending on flink task type).

Common situations: Task JSON hand-edited or generated by older UI versions missing required fields; parameter references not resolved leaving nulls; upgrading DolphinScheduler where parameter schema changed.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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