apache/dolphinscheduler · error · IllegalArgumentException

invalid code :

Error message

invalid code : 

What it means

ExecuteSqlType.of(Integer) throws IllegalArgumentException when the given code is not in VALUES_MAP. ExecuteSqlType classifies SQL statements in a data-quality task (e.g. the check/compare SQL vs output SQL); an unmapped code means a sql type parameter supplied to the data-quality engine is not recognized.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlType.java:65

    }

    public String getDescription() {
        return description;
    }

    private static final Map<Integer, ExecuteSqlType> VALUES_MAP = new HashMap<>();

    static {
        for (ExecuteSqlType type : ExecuteSqlType.values()) {
            VALUES_MAP.put(type.code, type);
        }
    }

    public static ExecuteSqlType of(Integer status) {
        if (VALUES_MAP.containsKey(status)) {
            return VALUES_MAP.get(status);
        }
        throw new IllegalArgumentException("invalid code : " + status);
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Verify each sqlType value in the data-quality task parameters matches an ExecuteSqlType constant and correct it.
  2. Use ExecuteSqlType enum constants when building parameter JSON.
  3. Remap legacy codes if parameters were persisted by an older DolphinScheduler version.
  4. Catch IllegalArgumentException around parsing and surface which sqlType value was invalid.

Example fix

// before
ExecuteSqlType sqlType = ExecuteSqlType.of(entry.getInt("sqlType"));

// after: default for unknown values
int code = entry.getInt("sqlType", -1);
ExecuteSqlType sqlType = code < 0 ? ExecuteSqlType.DEFAULT : ExecuteSqlType.of(code);
Defensive patterns

Strategy: validation

Validate before calling

static boolean isKnownSqlType(Integer code) {
    return code != null && Arrays.stream(ExecuteSqlType.values()).anyMatch(t -> t.getCode().equals(code));
}

Type guard

static Optional<ExecuteSqlType> safeOf(Integer status) {
    if (status == null) return Optional.empty();
    return Arrays.stream(ExecuteSqlType.values())
            .filter(t -> t.getCode().equals(status))
            .findFirst();
}

Try / catch

try {
    sqlType = ExecuteSqlType.of(code);
} catch (IllegalArgumentException e) {
    log.warn("Bad sqlType {} in data-quality params, skipping statement", code);
    sqlType = null;
}

Prevention

When it happens

Trigger: Calling ExecuteSqlType.of() with an Integer absent from VALUES_MAP — e.g. data-quality task parameters list SQL statements whose type field is 0/-1 or some code from another enum, or stored parameters reference removed type codes after an upgrade.

Common situations: Programmatically generating data-quality SQL parameter lists with a wrong type index; editing workflow JSON by hand; version skew between the API that writes parameters and the data-quality module that reads them.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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