alibaba/DataX · error · RuntimeException
TRANSFORMER_ILLEGAL_PARAMETER
TRANSFORMER_ILLEGAL_PARAMETER
Error message
dx_replace paras must be 4
What it means
Thrown by the dx_replace transformer when its paras array does not contain exactly 4 elements. dx_replace expects [columnIndex(int), startIndex(String), length(String), replaceString(String)]. The count check fires first inside the parameter-parsing try block, and the message is surfaced as TRANSFORMER_ILLEGAL_PARAMETER prefixed with the actual paras list.
Source
Thrown at core/src/main/java/com/alibaba/datax/core/transport/transformer/ReplaceTransformer.java:29
/**
* no comments.
* Created by liqiang on 16/3/4.
*/
public class ReplaceTransformer extends Transformer {
public ReplaceTransformer() {
setTransformerName("dx_replace");
}
@Override
public Record evaluate(Record record, Object... paras) {
int columnIndex;
int startIndex;
int length;
String replaceString;
try {
if (paras.length != 4) {
throw new RuntimeException("dx_replace paras must be 4");
}
columnIndex = (Integer) paras[0];
startIndex = Integer.valueOf((String) paras[1]);
length = Integer.valueOf((String) paras[2]);
replaceString = (String) paras[3];
} catch (Exception e) {
throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, "paras:" + Arrays.asList(paras).toString() + " => " + e.getMessage());
}
Column column = record.getColumn(columnIndex);
try {
String oriValue = column.asString();
//如果字段为空,跳过replace处理
if(oriValue == null){
return record;View on GitHub (pinned to 80ec23d5c5)
Solutions
- Provide exactly 4 parameters in order: column index (int), startIndex (numeric string), length (numeric string), replacement string.
- Verify the error payload: the message includes 'paras:[...]' showing what was actually parsed, so compare it against the expected 4-element shape.
- Ensure startIndex and length are quoted numeric strings (e.g. "2", "3") and columnIndex is a bare integer.
Example fix
// before "paras": [0, "2", "3"] // after "paras": [0, "2", "3", "REDACTED"]
Defensive patterns
Strategy: validation
Validate before calling
Object[] paras = ...;
if (paras.length != 4) throw new IllegalArgumentException("dx_replace needs [columnIndex, startIndex, length, replaceString]");
// also assert types: paras[0] instanceof Integer, paras[1..2] numeric strings Prevention
- Preflight-check paras.length against the transformer's documented arity (dx_replace=4, dx_substr=3, dx_pad=3).
- Use the 'paras:[...]' echo in the TRANSFORMER_ILLEGAL_PARAMETER message to diff actual vs expected shape.
When it happens
Trigger: A job JSON declares dx_replace with 3 or 5 parameters, e.g. "paras": [0, "0", "2"] (missing the replacement string) or including an extra trailing parameter. Also triggered if paras is not an array at all so its length differs from 4.
Common situations: Forgetting the final replaceString argument, mixing up dx_replace with dx_substr (which takes 3 parameters), or pasting a parameter list from a different transformer's documentation.
Related errors
- dx_pad first para(%s) support l or r
- TRANSFORMER_RUN_EXCEPTION
- TRANSFORMER_ILLEGAL_PARAMETER
- 您提供的配置文件有误. 路径[%s]需要配置Json格式的Map对象,但该节点发现实际类型是[%s]. 请检查您的配置并
- 您提供的配置文件有误. 路径[%s]值为null,datax无法识别该配置. 请检查您的配置并作出修改.
AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14).
Data as JSON: /api/errors/b861dead3f28320f.
Report an issue: GitHub.