{"record":{"id":"3fac2f6203565d4c","repo":"apache/seatunnel","slug":"delete-collection-error","errorCode":"DELETE_COLLECTION_ERROR","errorMessage":"DELETE_COLLECTION_ERROR.getDescription()","messagePattern":"DELETE_COLLECTION_ERROR\\.getDescription\\(\\)","errorType":"error_code","errorClass":"TypesenseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/client/TypesenseClient.java","lineNumber":271,"sourceCode":"    public boolean truncateCollectionData(String collection) {\n        DeleteDocumentsParameters deleteDocumentsParameters = new DeleteDocumentsParameters();\n        deleteDocumentsParameters.filterBy(\"id:!=1||id:=1\");\n        try {\n            tsClient.collections(collection).documents().delete(deleteDocumentsParameters);\n        } catch (Exception e) {\n            log.error(TRUNCATE_COLLECTION_ERROR.getDescription());\n            throw new TypesenseConnectorException(\n                    TRUNCATE_COLLECTION_ERROR, TRUNCATE_COLLECTION_ERROR.getDescription());\n        }\n        return true;\n    }\n\n    public boolean deleteCollectionData(String collection, String id) {\n        try {\n            tsClient.collections(collection).documents(id).delete();\n        } catch (Exception e) {\n            log.error(DELETE_COLLECTION_ERROR.getDescription());\n            throw new TypesenseConnectorException(\n                    DELETE_COLLECTION_ERROR, DELETE_COLLECTION_ERROR.getDescription());\n        }\n        return true;\n    }\n\n    public long collectionDocNum(String collection) {\n        SearchParameters q = new SearchParameters().q(\"*\");\n        try {\n            SearchResult searchResult = tsClient.collections(collection).documents().search(q);\n            return searchResult.getFound();\n        } catch (Exception e) {\n            log.error(QUERY_COLLECTION_NUM_ERROR.getDescription());\n            throw new TypesenseConnectorException(\n                    QUERY_COLLECTION_NUM_ERROR, QUERY_COLLECTION_NUM_ERROR.getDescription());\n        }\n    }\n}\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/client/TypesenseClient.java#L253-L289","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the Typesense node host/port/protocol and API key in the sink options are correct and the server is reachable.","Confirm the collection exists (curl the /collections/<name> endpoint) and matches the configured collection name.","Check that documents being deleted actually exist; pre-filter DELETE rows or tolerate missing ids.","Inspect server-side logs or wrap the call to capture the underlying cause, since this error message drops the original exception."],"exampleFix":"// before\ntry {\n    tsClient.collections(collection).documents(id).delete();\n} catch (Exception e) {\n    throw new TypesenseConnectorException(DELETE_COLLECTION_ERROR, DELETE_COLLECTION_ERROR.getDescription());\n}\n// after\ntry {\n    tsClient.collections(collection).documents(id).delete();\n} catch (Exception e) {\n    log.error(\"delete collection data failed, collection={}, id={}\", collection, id, e);\n    throw new TypesenseConnectorException(DELETE_COLLECTION_ERROR, DELETE_COLLECTION_ERROR.getDescription(), e);\n}","handlingStrategy":"try-catch","validationCode":"// before calling deleteCollectionData, verify collection and document exist\nboolean collectionExists = client.collections().get().stream()\n        .anyMatch(c -> c.getName().equals(collection));\nif (!collectionExists) throw new IllegalStateException(\"collection missing: \" + collection);","typeGuard":null,"tryCatchPattern":"try {\n    client.deleteCollectionData(collection, id);\n} catch (TypesenseConnectorException e) {\n    if (e.getErrorCode() == DELETE_COLLECTION_ERROR) {\n        // check connectivity / collection existence, then retry or skip\n    }\n}","preventionTips":["Confirm collection name and API key in the sink config before running the job.","Pre-check document existence for DELETE flows or treat missing documents as idempotent deletes.","Monitor Typesense server availability from the SeaTunnel worker host."],"tags":["typesense","http","connector-sink","document-delete"],"backgroundTag":"api-error-response","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}