alibaba/DataX · error · RuntimeException
dx_pad paras must be 4
Error message
dx_pad paras must be 4
What it means
The dx_pad transformer requires exactly 4 parameters; any other count throws RuntimeException('dx_pad paras must be 4'), rewrapped as DataXException(TRANSFORMER_ILLEGAL_PARAMETER). Expected paras: columnIndex (Integer), padType ('l'|'r' style left/right), target length (string-parsed Integer), and pad string.
Source
Thrown at core/src/main/java/com/alibaba/datax/core/transport/transformer/PadTransformer.java:30
* no comments.
* Created by liqiang on 16/3/4.
*/
public class PadTransformer extends Transformer {
public PadTransformer() {
setTransformerName("dx_pad");
}
@Override
public Record evaluate(Record record, Object... paras) {
int columnIndex;
String padType;
int length;
String padString;
try {
if (paras.length != 4) {
throw new RuntimeException("dx_pad paras must be 4");
}
columnIndex = (Integer) paras[0];
padType = (String) paras[1];
length = Integer.valueOf((String) paras[2]);
padString = (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();
//如果字段为空,作为空字符串处理
if(oriValue==null){
oriValue = "";View on GitHub (pinned to 80ec23d5c5)
Solutions
- Supply exactly 4 params: [columnIndex, padType, lengthAsString, padString], e.g. [0, "l", "5", "0"].
- Ensure the length parameter is a quoted string in job JSON.
- Validate transformer blocks with a JSON schema in your job-generation pipeline.
Example fix
// before
{"name": "dx_pad", "parameter": [0, "l", 5]}
// after
{"name": "dx_pad", "parameter": [0, "l", "5", "0"]} Defensive patterns
Strategy: validation
Validate before calling
Object[] p = {0, "l", "5", "0"};
if (p.length != 4) throw new IllegalArgumentException("dx_pad needs 4 paras");
Integer.parseInt((String) p[2]); // also validates numeric length Try / catch
catch (DataXException e) when TRANSFORMER_ILLEGAL_PARAMETER: fail fast, print paras; not retryable.
Prevention
- Quote the length parameter as a string in job JSON.
- Always include an explicit pad string; there is no default.
When it happens
Trigger: Declaring {"name":"dx_pad","parameter":[0,"l","5"]} (3 params) or 5 params in the job transformer block; also fires when paras[2] is not a number, since the catch wraps NumberFormatException with the same code.
Common situations: Omitting the pad string (assuming space default); passing length as a JSON number instead of a string — Integer.valueOf((String) paras[2]) requires a string.
Related errors
- dx_digest paras length must be 3
- dx_digest paras index 1 must be md5 or sha1
- dx_digest paras index 2 must be toUpperCase or toLowerCase
- dx_filter paras must be 3
- dx_filter para 2 can't be null
AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14).
Data as JSON: /api/errors/1ea6d6774c4bcb26.
Report an issue: GitHub.