milvus-io/milvus-sdk-node

Lack of error handling on invalid collection names

magnusdr opened this issue · 0 comments

Describe the bug:
I created a collection with hyphens in the name (e.g. my-first-collection), and was never notified about it being invalid.

Until I tried inserting data I got a somewhat confusing error:

TypeError: Cannot read properties of null (reading 'fields')
  at formatDescribedCol (/Users/magnusdr/fink/node_modules/@zilliz/milvus2-sdk-node/milvus/utils/Format.ts:345:15)
  at MilvusClient.<anonymous> (/Users/magnusdr/fink/node_modules/@zilliz/milvus2-sdk-node/milvus/grpc/Collection.ts:303:39)
  at Generator.next (<anonymous>)
  at fulfilled (/Users/magnusdr/fink/node_modules/@zilliz/milvus2-sdk-node/dist/milvus/grpc/Collection.js:5:58)
  at processTicksAndRejections (node:internal/process/task_queues:95:5)

formatDescribedCol fails because the data argument has schema: null, but if you look at it's status it says

status: {
  error_code: 'UnexpectedError',
  reason: 'Invalid collection name: public-fink-document-embeddings. Collection name can only contain numbers, letters, dollars and underscores.'
}

Steps to reproduce:

await client.createCollection({
  collection_name: 'my-first-collection',
  fields: [{
    name: 'id',
    data_type: DataType.Int64,
    description: 'Primary key',
    is_primary_key: true,
    autoID: true,
  }]
})
await client.insert({
   collection_name: MILVUS_PRIVATE_COLLECTION_NAME,
   fields_data: [],
});

Milvus-node-sdk version:
2.2.23

Milvus version:
2.0.2