{"record":{"id":"089cb9d046766df2","repo":"apache/beam","slug":"the-parameter-list-s-does-not-match-the-expected-fields-s","errorCode":null,"errorMessage":"The parameter list: %s does not match the expected fields: %s","messagePattern":"The parameter list: (.+?) does not match the expected fields: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/thrift/src/main/java/org/apache/beam/sdk/io/thrift/ThriftSchema.java","lineNumber":296,"sourceCode":"    final Map<String, TFieldIdEnum> fields =\n        fieldDescriptors.keySet().stream()\n            .collect(Collectors.toMap(TFieldIdEnum::getFieldName, Function.identity()));\n\n    return schema.getFields().stream()\n        .map(Schema.Field::getName)\n        .map(fields::get)\n        .collect(\n            Collectors.toMap(\n                Function.identity(),\n                fieldDescriptors::get,\n                ThriftSchema::throwingCombiner,\n                LinkedHashMap::new));\n  }\n\n  private <FieldT extends TFieldIdEnum, T extends TBase<T, FieldT>> T restoreThriftObject(\n      Class<?> targetClass, Map<FieldT, FieldMetaData> fields, Object[] params) {\n    if (params.length != fields.size()) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"The parameter list: %s does not match the expected fields: %s\",\n              Arrays.toString(params), fields.keySet()));\n    }\n    try {\n      @SuppressWarnings(\"unchecked\")\n      final T thrift = (T) targetClass.getDeclaredConstructor().newInstance();\n      final Iterator<Entry<FieldT, FieldMetaData>> iter = fields.entrySet().iterator();\n      Stream.of(params).forEach(param -> setThriftField(thrift, iter.next(), param));\n      return thrift;\n    } catch (Exception e) {\n      throw new IllegalStateException(e);\n    }\n  }\n\n  private <FieldT extends TFieldIdEnum, T extends TBase<T, FieldT>> void setThriftField(\n      T thrift, Entry<FieldT, FieldMetaData> fieldDescriptor, Object value) {\n    final FieldT field = fieldDescriptor.getKey();","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/thrift/src/main/java/org/apache/beam/sdk/io/thrift/ThriftSchema.java#L278-L314","documentation":"ThriftSchema.restoreThriftObject reconstructs a thrift instance from an array of field values built by schema-based creation. If the number of supplied parameters differs from the number of expected thrift fields, an IllegalArgumentException with this message is thrown, indicating the schema used to produce the values diverged from the thrift class metadata.","triggerScenarios":"Creating a thrift object through the Beam Schema type creator when the Row/parameter list has more or fewer fields than the TBase's registered field metadata — typically after the IDL changed while cached schemas/rows were not refreshed.","commonSituations":"Adding or removing a thrift field and replaying old Rows; running a pipeline with a stale thrift class version on one side; hand-constructed Object[] passed to the schema type creator.","solutions":["Regenerate thrift classes and refresh all Beam Schemas so field counts match","Ensure Rows read from older data are migrated to the current thrift schema before reconstruction","Check the message's parameter list vs expected fields to identify which side is stale"],"exampleFix":"// before\nRow row = rowWithOldSchema; // 3 fields, thrift class now has 4\nThriftRecord r = creator.create(ThriftRecord.class, row);\n// after\nSchema current = ThriftSchema.provider().schemaFor(TypeDescriptor.of(ThriftRecord.class));\nRow migrated = migrateRowToSchema(row, current);\nThriftRecord r = creator.create(ThriftRecord.class, migrated);","handlingStrategy":"validation","validationCode":"Schema inferred = ThriftSchema.provider().schemaFor(TypeDescriptor.of(ThriftRecord.class)); if (row.getSchema().getFieldCount() != inferred.getFieldCount()) { throw new IllegalArgumentException(\"row schema stale vs thrift class\"); }","typeGuard":null,"tryCatchPattern":"try { ThriftRecord r = creator.create(ThriftRecord.class, row); } catch (IllegalArgumentException e) { LOG.error(\"row/thrift field count mismatch: {}\", e.getMessage()); throw e; }","preventionTips":["Version Rows and migrate them when the thrift IDL changes","Regenerate thrift classes and schemas together in one release","Never hand-construct Object[] parameter lists for schema type creators"],"tags":["java","thrift","schema","reflection"],"backgroundTag":"shape-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}