{"record":{"id":"76c0702a57e14bfc","repo":"apache/iceberg","slug":"invalid-argument-argsstr-should-have-2-parts","errorCode":null,"errorMessage":"Invalid argument ${argsStr}, should have 2 parts","messagePattern":"Invalid argument (.+?), should have 2 parts","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/SchemaUtils.java","lineNumber":210,"sourceCode":"                {\n                  Pair<String, Integer> args = transformArgPair(matcher.group(2));\n                  specBuilder.truncate(args.first(), args.second());\n                  break;\n                }\n              default:\n                throw new UnsupportedOperationException(\"Unsupported transform: \" + transform);\n            }\n          } else {\n            specBuilder.identity(partitionField);\n          }\n        });\n    return specBuilder.build();\n  }\n\n  private static Pair<String, Integer> transformArgPair(String argsStr) {\n    List<String> parts = Splitter.on(',').splitToList(argsStr);\n    if (parts.size() != 2) {\n      throw new IllegalArgumentException(\"Invalid argument \" + argsStr + \", should have 2 parts\");\n    }\n    return Pair.of(parts.get(0).trim(), Integer.parseInt(parts.get(1).trim()));\n  }\n\n  static Type toIcebergType(Schema valueSchema, IcebergSinkConfig config) {\n    return new SchemaGenerator(config).toIcebergType(valueSchema);\n  }\n\n  static Type inferIcebergType(Object value, IcebergSinkConfig config) {\n    return new SchemaGenerator(config).inferIcebergType(value);\n  }\n\n  static class SchemaGenerator {\n\n    private int fieldId = 1;\n    private final IcebergSinkConfig config;\n\n    SchemaGenerator(IcebergSinkConfig config) {","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/SchemaUtils.java#L192-L228","documentation":"transformArgPair parses the arguments of a parameterized partition transform (e.g. bucket[N], truncate[W]) expecting exactly one comma-separated pair: a column name and an integer width/count. Any other arity throws IllegalArgumentException.","triggerScenarios":"iceberg.partition-by containing \"bucket(col)\" without N, \"truncate(col,10,extra)\", or a stray comma like \"bucket(col,,16)\".","commonSituations":"Hand-edited connector configs; copied examples missing the bucket count; commas inside quoted defaults.","solutions":["Write transform args as exactly two parts: \"bucket(16,user_id)\", \"truncate(10,name)\".","Remove extra commas or missing numeric argument.","Test the config on a staging connector; the error names the offending argument string."],"exampleFix":"// before\n\"iceberg.partition-by\": \"bucket(user_id)\"\n// after\n\"iceberg.partition-by\": \"bucket(16,user_id)\"","handlingStrategy":"validation","validationCode":"String args = expr.substring(expr.indexOf('(') + 1, expr.length() - 1);\nif (expr.contains(\"(\") && args.split(\",\").length != 2)\n  throw new ConfigException(\"Transform needs exactly 2 args: \" + expr);","typeGuard":null,"tryCatchPattern":"try { spec = SchemaUtils.createPartitionSpec(schema, List.of(\"bucket(16,user_id)\")); }\ncatch (IllegalArgumentException e) { throw new ConfigException(e.getMessage(), e); }","preventionTips":["Always include the numeric argument: bucket(N,col), truncate(W,col)","Avoid spaces/extra commas inside transform args","Lint connector configs for the partition-by syntax"],"tags":["kafka-connect","partitioning","argument-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}