apache/seatunnel · error · MongodbConnectorException

ILLEGAL_ARGUMENT

ILLEGAL_ARGUMENT

Error message

Inconsistent naming found at index ${i}: The collection name '${collectionName}' must match the schema table name '${fullName}'.

What it means

MongodbIncrementalSourceFactory.updateAndValidateCatalogTableId reconciles user-provided collection names against catalog table metadata. When a catalog table's full name (db.collection) disagrees with the corresponding configured collection name and the identifier isn't just a bare collection name, it throws MongodbConnectorException(ILLEGAL_ARGUMENT) flagging inconsistent naming at the given index.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mongodb/MongodbIncrementalSourceFactory.java:118

                    new MongodbIncrementalSource<>(context.getOptions(), catalogTables);
        };
    }

    private List<CatalogTable> updateAndValidateCatalogTableId(
            List<CatalogTable> catalogTables, List<String> collections) {
        for (int i = 0; i < catalogTables.size(); i++) {
            CatalogTable catalogTable = catalogTables.get(i);
            String collectionName = collections.get(i);
            String fullName = catalogTable.getTablePath().getFullName();
            if (fullName.equals(TablePath.DEFAULT.getFullName())) {
                if (catalogTables.size() == 1) {
                    TableIdentifier updatedIdentifier =
                            TableIdentifier.of(
                                    catalogTable.getCatalogName(), TablePath.of(collectionName));
                    return Collections.singletonList(
                            CatalogTable.of(updatedIdentifier, catalogTable));
                } else if (!fullName.equals(collectionName)) {
                    throw new MongodbConnectorException(
                            ILLEGAL_ARGUMENT,
                            String.format(
                                    "Inconsistent naming found at index %d: The collection name '%s' must match the schema table name '%s'.",
                                    i, collectionName, fullName));
                }
            }
        }
        return catalogTables;
    }

    private void validateCatalogTablesAndCollections(
            List<CatalogTable> catalogTables, List<String> collections) {
        if (catalogTables.size() != collections.size()) {
            throw new MongodbConnectorException(
                    ILLEGAL_ARGUMENT,
                    "The number of collections must be equal to the number of schema tables");
        }
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Make the configured collection names exactly match the catalog's database.collection full names
  2. Verify order of entries matches between config and catalog resolution
  3. Use the full 'database.collection' format in table-names to avoid ambiguity
  4. Fix the typo causing the mismatch reported at index i

Example fix

// before
table-names = ["mycoll", "otherdb.othercoll"]
// after
table-names = ["mydb.mycoll", "otherdb.othercoll"]
Defensive patterns

Strategy: validation

Validate before calling

// Ensure collection entries match catalog full names before createSource
List<String> configured = ...; List<String> fullNames = ...;
for (int i = 0; i < configured.size(); i++) {
  if (!fullNames.contains(configured.get(i)) && !configured.get(i).equals(fullNames.get(i)))
    throw new IllegalArgumentException("Mismatch at " + i + ": " + configured.get(i) + " vs " + fullNames.get(i));
}

Try / catch

try { factory.createSource(context); } catch (MongodbConnectorException e) { if (e.getSeaTunnelErrorCode() == MongodbConnectorErrorCode.ILLEGAL_ARGUMENT && e.getMessage().contains("Inconsistent naming")) { /* align table-names with catalog db.collection names */ } throw e; }

Prevention

When it happens

Trigger: The table-names/ collection config list and the catalog's resolved full names (database.collection) diverge in order or spelling — e.g. configuring a bare collection name in one place and db.collection in another, or two entries swapped.

Common situations: Configured 'mycoll' but catalog expects 'mydb.mycoll' with a different entry ordering; typo in one of the two lists; using database list + collection list that don't align index-wise.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/ac59804741d5152c. Report an issue: GitHub.