apache/dolphinscheduler · error · TaskException

sql task params is not valid

Error message

sql task params is not valid

What it means

The SqlTask constructor parses the task params JSON into SqlParameters and immediately validates: if parsing fails (null result) or checkParameters() returns false, it throws TaskException("sql task params is not valid"). checkParameters() requires non-empty sql (or a non-empty pre/post statement) plus a type; a SQL task instance cannot even be constructed without them.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java:106

    /**
     * default query sql limit
     */
    private static final int QUERY_LIMIT = 10000;

    private final SQLTaskExecutionContext sqlTaskExecutionContext;

    private final DbType dbType;

    private Connection sessionConnection;
    private Statement sessionStatement;

    public SqlTask(TaskExecutionContext taskRequest) {
        super(taskRequest);
        this.taskExecutionContext = taskRequest;
        this.sqlParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), SqlParameters.class);
        log.info("Initialize sql task parameter {}", JSONUtils.toPrettyJsonString(sqlParameters));
        if (sqlParameters == null || !sqlParameters.checkParameters()) {
            throw new TaskException("sql task params is not valid");
        }
        if (this.sqlParameters.getDatasource() == 0) {
            throw new TaskException("unbound test data source");
        }

        sqlTaskExecutionContext =
                sqlParameters.generateExtendedContext(taskExecutionContext.getResourceParametersHelper());
        dbType = DbType.valueOf(sqlParameters.getType());
    }

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

    @Override
    public void handle(TaskCallBack taskCallBack) throws TaskException {
        log.info("Full sql parameters: {}", sqlParameters);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Open the SQL task node, ensure the SQL statement is non-empty and a database type is selected, then re-save
  2. Validate the stored task params JSON parses into SqlParameters with checkParameters()==true before scheduling the workflow
  3. If this appeared after an upgrade/re-import, re-export/re-import the workflow definition and confirm taskParams fields match the current SqlParameters schema

Example fix

// before
{"taskType":"SQL","taskParams":{"type":"MYSQL","datasource":3}}
// after (sql must be non-empty)
{"taskType":"SQL","taskParams":{"type":"MYSQL","datasource":3,"sql":"select 1"}}
Defensive patterns

Strategy: validation

Validate before calling

SqlParameters p = JSONUtils.parseObject(taskParams, SqlParameters.class);
if (p == null || !p.checkParameters()) {
    throw new IllegalArgumentException("sql params invalid: sql and type must be non-empty");
}

Type guard

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

Try / catch

try {
    SqlTask task = new SqlTask(taskExecutionContext); // throws in constructor
} catch (TaskException e) {
    // params missing/invalid: fix taskParams JSON before retry
}

Prevention

When it happens

Trigger: taskExecutionContext.getTaskParams() is null, empty, malformed JSON, or yields SqlParameters with an empty sql field and empty preStatements/postStatements, or a blank type.

Common situations: SQL task node saved with an empty SQL editor; datasource plugin upgrade changing SqlParameters field names so old JSON no longer deserializes; API workflow import with truncated taskParams JSON; invalid characters breaking JSONUtils parsing.

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/8e6defbbe8434532. Report an issue: GitHub.