{"record":{"id":"7985a512d3a245a2","repo":"apache/seatunnel","slug":"query-collection-exists-error","errorCode":"QUERY_COLLECTION_EXISTS_ERROR","errorMessage":"QUERY_COLLECTION_EXISTS_ERROR.getDescription()","messagePattern":"QUERY_COLLECTION_EXISTS_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":150,"sourceCode":"        searchParameters.perPage(pageSize);\n        SearchResult searchResult =\n                tsClient.collections(collection).documents().search(searchParameters);\n        return searchResult;\n    }\n\n    public boolean collectionExists(String collection) {\n        try {\n            Collections collections = tsClient.collections();\n            CollectionResponse[] collectionResponses = collections.retrieve();\n            for (CollectionResponse collectionRespons : collectionResponses) {\n                String collectionName = collectionRespons.getName();\n                if (collection.equals(collectionName)) {\n                    return true;\n                }\n            }\n        } catch (Exception e) {\n            log.error(QUERY_COLLECTION_EXISTS_ERROR.getDescription());\n            throw new TypesenseConnectorException(\n                    QUERY_COLLECTION_EXISTS_ERROR, QUERY_COLLECTION_EXISTS_ERROR.getDescription());\n        }\n        return false;\n    }\n\n    public List<String> collectionList() {\n        try {\n            Collections collections = tsClient.collections();\n            CollectionResponse[] collectionResponses = collections.retrieve();\n            List<String> list = new ArrayList<>();\n            for (CollectionResponse collectionRespons : collectionResponses) {\n                String collectionName = collectionRespons.getName();\n                list.add(collectionName);\n            }\n            return list;\n        } catch (Exception e) {\n            log.error(QUERY_COLLECTION_LIST_ERROR.getDescription());\n            throw new TypesenseConnectorException(","sourceCodeStart":132,"sourceCodeEnd":168,"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#L132-L168","documentation":"TypesenseClient.collectionExists() lists all collections and matches by name; any exception from the Typesense API (connectivity, auth, server error) is caught and rethrown as TypesenseConnectorException with QUERY_COLLECTION_EXISTS_ERROR. The underlying cause is discarded.","triggerScenarios":"Calling collectionExists (directly or via getField/createCollection) while the Typesense endpoint is down, the API key is invalid, or the retrieve-collections API call fails.","commonSituations":"Misconfigured TypesenseUrl/TypesenseApiKey in the SeaTunnel config; Typesense cluster restart or TLS mismatch; collection name checks during schema auto-creation in a catalog.","solutions":["Verify Typesense URL and API key in the connector configuration and test with curl /collections","Check Typesense server health/logs and network reachability from the SeaTunnel worker","Chain the original exception when rethrowing so the real failure is visible","Retry the existence check after transient failures (connection resets, leader election in the Typesense cluster)"],"exampleFix":"// before\n} catch (Exception e) {\n    log.error(QUERY_COLLECTION_EXISTS_ERROR.getDescription());\n    throw new TypesenseConnectorException(QUERY_COLLECTION_EXISTS_ERROR, QUERY_COLLECTION_EXISTS_ERROR.getDescription());\n}\n// after\n} catch (Exception e) {\n    log.error(QUERY_COLLECTION_EXISTS_ERROR.getDescription(), e);\n    throw new TypesenseConnectorException(QUERY_COLLECTION_EXISTS_ERROR, QUERY_COLLECTION_EXISTS_ERROR.getDescription(), e);\n}","handlingStrategy":"try-catch","validationCode":"// pre-check connectivity/credentials with a lightweight call\nHttpResponse<String> resp = httpClient.send(requestTo(typesenseUrl + \"/collections\"), BodyHandlers.ofString());\nboolean apiReachable = resp.statusCode() == 200;","typeGuard":null,"tryCatchPattern":"try {\n    exists = client.collectionExists(collection);\n} catch (TypesenseConnectorException e) {\n    // treat as indeterminate; check URL/API key and retry with backoff\n}","preventionTips":["Verify TypesenseUrl and TypesenseApiKey in config before job launch","Retry existence checks on transient cluster failures","Prefer a direct GET /collections/{name} (404 = absent) over full listing for reliability"],"tags":["typesense","collection-exists","api-error"],"backgroundTag":"http-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"}