apache/dolphinscheduler · error · TaskException

unbound test data source

Error message

unbound test data source

What it means

Right after the params-validity check, the SqlTask constructor rejects tasks whose sqlParameters.getDatasource() == 0, throwing TaskException("unbound test data source"). Datasource id 0 means no datasource was bound to the node, so the task has no target database. Despite the message wording, this is the generic unbound-datasource check for every SQL task.

Source

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

    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);
        log.info(
                "sql type : {}, datasource : {}, sql : {} , localParams : {},showType : {},connParams : {},varPool : {} ,query max result limit  {}",
                sqlParameters.getType(),

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Open the SQL task node and select a valid datasource from the dropdown, then re-save the workflow
  2. When building workflows via API/SDK, explicitly set datasource to the numeric id of an existing datasource in taskParams
  3. Verify the datasource id exists for the project (datasources API / t_ds_datasource) if importing definitions across environments

Example fix

// before
{"taskType":"SQL","taskParams":{"type":"MYSQL","datasource":0,"sql":"select 1"}}
// after
{"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.getDatasource() == 0) {
    throw new IllegalArgumentException("sql task has no datasource bound");
}

Type guard

boolean hasDatasource(String json) {
    SqlParameters p = JSONUtils.parseObject(json, SqlParameters.class);
    return p != null && p.getDatasource() > 0;
}

Prevention

When it happens

Trigger: A SQL task node was created/saved without selecting a datasource (datasourceId defaults to 0); a workflow definition was imported/API-submitted with datasource absent or 0 in taskParams.

Common situations: Datasource referenced by the task was deleted and a re-saved template lost the binding; programmatic workflow creation omitted the datasource field; copying a task between projects where the datasource id does not exist in the target project.

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/9d8272889601e85f. Report an issue: GitHub.