datastax / astra-db-ts

Typescript client for Astra DB Vector
https://astra.datastax.com/register
Apache License 2.0
12 stars 4 forks source link

createCollection should throw a catchable error #11

Closed mfortman11 closed 3 months ago

mfortman11 commented 6 months ago

When implementing a create if does not exist type of method the logs are bogged down w/ error logs and the error is not catchable.

This method should throw an appropriate error or we should have a create if does not exist method

error: Error: Command "createCollection" failed with the following errors: [{"message":"Server call failed, please retry!"}]
    at handleIfErrorResponse (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/client/httpClient.js:226:15)
    at HTTPClient.executeCommand (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/client/httpClient.js:206:43)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/collections/db.js:67:20
    at async executeOperation (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/collections/utils.js:161:15)
    at async AstraDB.createCollection (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@datastax/astra-db-ts/dist/collections/client.js:73:16)
    at async AstraDBVectorStore.initialize (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@langchain/community/dist/vectorstores/astradb.cjs:88:13)
    at async AstraDBVectorStore.fromDocuments (/Users/mendon.kissling/Documents/GitHub/temporary-astra/node-test-applications/node_modules/@langchain/community/dist/vectorstores/astradb.cjs:226:9)
Collection already exists, connecting to vector_test
Yuqi-Du commented 6 months ago

I actually can not reproduce this error. Could you provide more details?

If you have already got a target collection in the db, recreation with same settings will not have a error. However, recreation with different settings will give you back this:

error: Error: Command "createCollection" failed with the following errors: [{"message":"The provided collection name 'collection_simple' already exists with a non-vector setting.","errorCode":"INVALID_COLLECTION_NAME"}]

nicoloboschi commented 5 months ago

I think @mfortman11 was referring to the LangChain implementation whereas this happens:

https://github.com/langchain-ai/langchainjs/blob/b2151ec4d546ff71c7045883251e839042fb4485/libs/langchain-community/src/vectorstores/astradb.ts#L90-L103

so any error server error results in "collection already exists, go ahead" which is totally wrong. But we should fix it in langchain.

toptobes commented 5 months ago

Added in 39ad42e37fb14711041cc6ec905bbfa4c745944e in signature-cleanup—will close issue when merged

toptobes commented 3 months ago

Not an issue anymore in the v1.0.0 release