apache/seatunnel · error · TableNotExistException

Table ${tablePath} does not exist in catalog ${name()}

Error message

Table ${tablePath} does not exist in catalog ${name()}

What it means

This error is raised by MongodbCatalog.dropTable when the requested collection does not exist and ignoreIfNotExists is false. It fires when a drop-table operation targets a database or collection name that has no corresponding collection in MongoDB, typically due to a misspelled collection name, wrong database, or a collection already dropped by a concurrent job; pass ignoreIfNotExists=true to make the drop a no-op instead.

Source

Thrown at seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java:149

        if (tableExists(tablePath)) {
            if (ignoreIfExists) return;
            throw new TableAlreadyExistException(name(), tablePath);
        }
        try {
            MongoDatabase db = mongoClient.getDatabase(tablePath.getDatabaseName());
            db.createCollection(tablePath.getTableName());
        } catch (Exception e) {
            throw new CatalogException(
                    "Failed to create collection: " + tablePath.getFullName(), e);
        }
    }

    @Override
    public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)
            throws TableNotExistException, CatalogException {
        if (!tableExists(tablePath)) {
            if (ignoreIfNotExists) return;
            throw new TableNotExistException(name(), tablePath);
        }
        try {
            MongoDatabase db = mongoClient.getDatabase(tablePath.getDatabaseName());
            db.getCollection(tablePath.getTableName()).drop();
        } catch (Exception e) {
            throw new CatalogException("Failed to drop collection: " + tablePath.getFullName(), e);
        }
    }

    @Override
    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)
            throws DatabaseAlreadyExistException, CatalogException {
        throw CommonError.unsupportedOperation(name(), "create database ");
    }

    @Override
    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)
            throws DatabaseNotExistException, CatalogException {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Pass ignoreIfNotExists=true to make dropping a missing collection a no-op.
  2. Check catalog.tableExists(tablePath) before dropping.
  3. Verify the table path (database and collection names) matches the target environment.
  4. If it must exist, investigate why it is missing before dropping (was it dropped already?).

Example fix

// before
catalog.dropTable(tablePath, false);
// after
catalog.dropTable(tablePath, true); // idempotent drop
Defensive patterns

Strategy: validation

Validate before calling

if (!catalog.tableExists(tablePath)) {
    return; // nothing to drop
}

Try / catch

try {
    catalog.dropTable(tablePath, false);
} catch (TableNotExistException e) {
    // expected on idempotent cleanup; ignore or log
}

Prevention

When it happens

Trigger: Calling dropTable on a (database, collection) that does not exist with ignoreIfNotExists=false; typo in the table path; the collection was already dropped by a previous run or another process.

Common situations: Cleanup scripts running twice, wrong environment (dropping in prod vs dev name), case mismatch in the collection name.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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