apache/seatunnel · error · TypesenseConnectorException

DELETE_COLLECTION_ERROR

DELETE_COLLECTION_ERROR

Error message

DELETE_COLLECTION_ERROR.getDescription()

What it means

TypesenseClient.deleteCollectionData deletes a single document from a Typesense collection by id. When the underlying org.typesense Java client throws for any reason (network failure, missing collection, missing document, auth failure), the client logs and rethrows a TypesenseConnectorException with the generic DELETE_COLLECTION_ERROR code, discarding the original cause.

Solutions

  1. Verify the Typesense node host/port/protocol and API key in the sink options are correct and the server is reachable.
  2. Confirm the collection exists (curl the /collections/<name> endpoint) and matches the configured collection name.
  3. Check that documents being deleted actually exist; pre-filter DELETE rows or tolerate missing ids.
  4. Inspect server-side logs or wrap the call to capture the underlying cause, since this error message drops the original exception.

Example fix

// before
try {
    tsClient.collections(collection).documents(id).delete();
} catch (Exception e) {
    throw new TypesenseConnectorException(DELETE_COLLECTION_ERROR, DELETE_COLLECTION_ERROR.getDescription());
}
// after
try {
    tsClient.collections(collection).documents(id).delete();
} catch (Exception e) {
    log.error("delete collection data failed, collection={}, id={}", collection, id, e);
    throw new TypesenseConnectorException(DELETE_COLLECTION_ERROR, DELETE_COLLECTION_ERROR.getDescription(), e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before calling deleteCollectionData, verify collection and document exist
boolean collectionExists = client.collections().get().stream()
        .anyMatch(c -> c.getName().equals(collection));
if (!collectionExists) throw new IllegalStateException("collection missing: " + collection);

Try / catch

try {
    client.deleteCollectionData(collection, id);
} catch (TypesenseConnectorException e) {
    if (e.getErrorCode() == DELETE_COLLECTION_ERROR) {
        // check connectivity / collection existence, then retry or skip
    }
}

Prevention

When it happens

Trigger: typesenseClient.deleteCollectionData(collection, id) is called and the Typesense server is unreachable, the collection does not exist, the document id does not exist, or the API key lacks delete permission. Also invoked from TypesenseSinkWriter.write for RowKind DELETE/UPDATE_BEFORE rows.

Common situations: Sink writing CDC/DELETE rows against a collection that was dropped or renamed; wrong collection name in sink config; Typesense host/port/API key misconfigured; document already deleted so the delete fails; network partition between the SeaTunnel worker and Typesense.

Related errors


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

Appendix: source

Thrown at seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/client/TypesenseClient.java:271

    public boolean truncateCollectionData(String collection) {
        DeleteDocumentsParameters deleteDocumentsParameters = new DeleteDocumentsParameters();
        deleteDocumentsParameters.filterBy("id:!=1||id:=1");
        try {
            tsClient.collections(collection).documents().delete(deleteDocumentsParameters);
        } catch (Exception e) {
            log.error(TRUNCATE_COLLECTION_ERROR.getDescription());
            throw new TypesenseConnectorException(
                    TRUNCATE_COLLECTION_ERROR, TRUNCATE_COLLECTION_ERROR.getDescription());
        }
        return true;
    }

    public boolean deleteCollectionData(String collection, String id) {
        try {
            tsClient.collections(collection).documents(id).delete();
        } catch (Exception e) {
            log.error(DELETE_COLLECTION_ERROR.getDescription());
            throw new TypesenseConnectorException(
                    DELETE_COLLECTION_ERROR, DELETE_COLLECTION_ERROR.getDescription());
        }
        return true;
    }

    public long collectionDocNum(String collection) {
        SearchParameters q = new SearchParameters().q("*");
        try {
            SearchResult searchResult = tsClient.collections(collection).documents().search(q);
            return searchResult.getFound();
        } catch (Exception e) {
            log.error(QUERY_COLLECTION_NUM_ERROR.getDescription());
            throw new TypesenseConnectorException(
                    QUERY_COLLECTION_NUM_ERROR, QUERY_COLLECTION_NUM_ERROR.getDescription());
        }
    }
}

View on GitHub (pinned to cf67b549a7)