{"record":{"id":"a01650b2656964f6","repo":"apache/seatunnel","slug":"illegal-argument-a01650","errorCode":"ILLEGAL_ARGUMENT","errorMessage":"fieldName is empty","messagePattern":"fieldName is empty","errorType":"error_code","errorClass":"MongodbConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/serde/DocumentRowDataDeserializer.java","lineNumber":45,"sourceCode":"\nimport static org.apache.seatunnel.api.table.type.SqlType.STRING;\nimport static org.apache.seatunnel.common.exception.CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT;\nimport static org.apache.seatunnel.common.exception.CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION;\n\npublic class DocumentRowDataDeserializer implements DocumentDeserializer<SeaTunnelRow> {\n\n    private final String[] fieldNames;\n\n    private final SeaTunnelDataType<?>[] fieldTypes;\n\n    private final BsonToRowDataConverters bsonConverters;\n\n    private final boolean flatSyncString;\n\n    public DocumentRowDataDeserializer(\n            String[] fieldNames, SeaTunnelDataType<?> dataTypes, boolean flatSyncString) {\n        if (fieldNames == null || fieldNames.length < 1) {\n            throw new MongodbConnectorException(ILLEGAL_ARGUMENT, \"fieldName is empty\");\n        }\n        this.bsonConverters = new BsonToRowDataConverters();\n        this.fieldNames = fieldNames;\n        this.fieldTypes = ((SeaTunnelRowType) dataTypes).getFieldTypes();\n        this.flatSyncString = flatSyncString;\n    }\n\n    @Override\n    public SeaTunnelRow deserialize(BsonDocument bsonDocument) {\n        if (flatSyncString) {\n            if (fieldNames.length != 1 && fieldTypes[0].getSqlType() != STRING) {\n                throw new MongodbConnectorException(\n                        UNSUPPORTED_OPERATION,\n                        \"By utilizing flatSyncString, only one field attribute value can be set, and the field type must be a String. This operation will perform a string mapping on a single MongoDB data entry.\");\n            }\n            SeaTunnelRow rowData = new SeaTunnelRow(fieldNames.length);\n            rowData.setField(\n                    0, bsonConverters.createConverter(fieldTypes[0]).convert(bsonDocument));","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/serde/DocumentRowDataDeserializer.java#L27-L63","documentation":"Constructor validation of DocumentRowDataDeserializer: the fieldNames array must be non-null and contain at least one column, because the deserializer maps every BSON document onto a SeaTunnelRow with those field names. An empty or null array makes row mapping impossible, so construction fails fast.","triggerScenarios":"Instantiating DocumentRowDataDeserializer with fieldNames == null or fieldNames.length == 0 — typically from a source connector built with an empty catalog table / query projection that resolved to zero columns.","commonSituations":"MongoDB source config where the 'schema'/'fields' option parses to an empty list; programmatic use of the connector API with an unpopulated SeaTunnelRowType; a projection/collection filter that matched no fields.","solutions":["Provide a non-empty field list in the connector schema config (e.g. define 'schema' fields in the MongoDB source options).","Verify the SeaTunnelRowType passed to the deserializer has at least one field.","Check any query/projection options that could yield an empty column set.","If fields are derived dynamically, add a fallback/default field set before constructing the deserializer."],"exampleFix":"// before\nnew DocumentRowDataDeserializer(new String[0], rowType, false) // throws\n// after\nnew DocumentRowDataDeserializer(new String[]{\"_id\", \"name\"}, rowType, false)","handlingStrategy":"validation","validationCode":"// validate before construction\nif (fieldNames == null || fieldNames.length == 0) { throw new IllegalArgumentException(\"at least one field is required\"); }","typeGuard":null,"tryCatchPattern":"try { deserializer = new DocumentRowDataDeserializer(fieldNames, rowType, flatSyncString); } catch (MongodbConnectorException e) { if (e.getMessage().equals(\"fieldName is empty\")) { fieldNames = defaultFieldNames(); deserializer = new DocumentRowDataDeserializer(fieldNames, rowType, flatSyncString); } else { throw e; } }","preventionTips":["Always define at least one field in the MongoDB source schema config","Check that dynamic schema discovery cannot produce an empty column list","Log/validate the resolved SeaTunnelRowType before creating deserializers","Review projection options that may strip all fields"],"tags":["mongodb","constructor","validation","serde"],"backgroundTag":"empty-required-field","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}