{"record":{"id":"949419afc72c1b32","repo":"alibaba/DataX","slug":"dx-pad-first-para-s-support-l-or-r","errorCode":null,"errorMessage":"dx_pad first para(%s) support l or r","messagePattern":"dx_pad first para\\((.+?)\\) support l or r","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/datax/core/transport/transformer/PadTransformer.java","lineNumber":52,"sourceCode":"            padType = (String) paras[1];\n            length = Integer.valueOf((String) paras[2]);\n            padString = (String) paras[3];\n        } catch (Exception e) {\n            throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, \"paras:\" + Arrays.asList(paras).toString() + \" => \" + e.getMessage());\n        }\n\n        Column column = record.getColumn(columnIndex);\n\n        try {\n            String oriValue = column.asString();\n\n            //如果字段为空，作为空字符串处理\n            if(oriValue==null){\n                oriValue = \"\";\n            }\n            String newValue;\n            if (!padType.equalsIgnoreCase(\"r\") && !padType.equalsIgnoreCase(\"l\")) {\n                throw new RuntimeException(String.format(\"dx_pad first para(%s) support l or r\", padType));\n            }\n            if (length <= oriValue.length()) {\n                newValue = oriValue.substring(0, length);\n            } else {\n\n                newValue = doPad(padType, oriValue, length, padString);\n            }\n\n            record.setColumn(columnIndex, new StringColumn(newValue));\n\n        } catch (Exception e) {\n            throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(),e);\n        }\n        return record;\n    }\n\n    private String doPad(String padType, String oriValue, int length, String padString) {\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/core/src/main/java/com/alibaba/datax/core/transport/transformer/PadTransformer.java#L34-L70","documentation":"Thrown by the dx_pad transformer when its first parameter (padType) is neither 'l' nor 'r' (case-insensitive). dx_pad pads or truncates a string column to a fixed length, aligning left ('l') or right ('r') with a pad string. Any other value for the first parameter is rejected before padding is attempted, and the original RuntimeException is rewrapped as TRANSFORMER_RUN_EXCEPTION by the surrounding catch.","triggerScenarios":"A job JSON uses the dx_pad transformer with a paras array whose first element is not exactly 'l', 'L', 'r', or 'R', e.g. \"paras\": [\"left\", \"10\", \"*\"] or \"paras\": [\"R \", ...]. The check runs on every record, so the job fails on the first record of the first column the transformer touches.","commonSituations":"Copying a pad example from another tool that uses 'left'/'right', trailing whitespace in the parameter string, or a typo such as 'L,' or uppercase-mixed values with invisible characters. Note paras[0] here is compared as a String, unlike some transformers where it is an integer column index.","solutions":["Set the first element of the transformer's paras array to exactly \"l\" or \"r\" (e.g. \"paras\": [\"r\", \"10\", \"0\"]) in the job JSON.","Check for stray whitespace or quotes around the value in the job configuration file.","Confirm the transformer parameter order: padType first, then length, then pad string.","Re-run the job and verify the padded output on a few sample rows."],"exampleFix":"// before (job JSON)\n\"transformer\": [{ \"name\": \"dx_pad\", \"parameter\": { \"columnIndex\": 2, \"paras\": [\"right\", \"10\", \"0\"] } }]\n// after\n\"transformer\": [{ \"name\": \"dx_pad\", \"parameter\": { \"columnIndex\": 2, \"paras\": [\"r\", \"10\", \"0\"] } }]","handlingStrategy":"validation","validationCode":"// job config lint before submit\nJSONObject t = transformer;\nString padType = (String) t.getJSONArray(\"paras\").getString(0);\nif (!\"l\".equalsIgnoreCase(padType) && !\"r\".equalsIgnoreCase(padType))\n    throw new IllegalArgumentException(\"dx_pad paras[0] must be 'l' or 'r', got: \" + padType);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate transformer parameter shape in a job-config preflight script before submitting to DataX.","Keep a reviewed library of known-good transformer parameter blocks and copy from there only."],"tags":["datax","transformer","dx-pad","configuration"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}