Skip to content

Milvus fails to insert documents if metadata is longerΒ #10063

@florianleimer

Description

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

import { Milvus } from '@langchain/community/vectorstores/milvus';
import { Document } from '@langchain/core/documents';
import { OpenAIEmbeddings } from '@langchain/openai';

const vectorStore = await Milvus.fromDocuments(
  [
    new Document({
      metadata: {
        description: 'Short description',
      },
      pageContent: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr',
    }),
  ],
  new OpenAIEmbeddings(),
  {
    collectionName: 'goldel_escher_bach',
  },
);

await vectorStore.addDocuments([
  new Document({
    metadata: {
      description: 'This is a longer description',
    },
    pageContent: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr',
  }),
]);

Error Message and Stack Trace (if applicable)

file:///var/www/html/node_modules/@langchain/community/dist/vectorstores/milvus.js:171
                if (insertResp.status.error_code !== ErrorCode.SUCCESS) throw new Error(`Error ${this.autoId ? "inserting" : "upserting"} data: ${JSON.stringify(insertResp)}`);
                                                                              ^

Error: Error inserting data: {"succ_index":[],"err_index":[0],"status":{"extra_info":{},"error_code":"IllegalArgument","reason":"length of varchar field description exceeds max length, row number: 0, length: 28, max length: 17: invalid parameter","code":1100,"retriable":false,"detail":"length of varchar field description exceeds max length, row number: 0, length: 28, max length: 17: invalid parameter"},"IDs":null,"acknowledged":false,"insert_cnt":"0","delete_cnt":"0","upsert_cnt":"0","timestamp":"0"}
    at Milvus.addVectors (file:///var/www/html/node_modules/@langchain/community/dist/vectorstores/milvus.js:171:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async Milvus.addDocuments (file:///var/www/html/node_modules/@langchain/community/dist/vectorstores/milvus.js:119:3)
    at async file:///var/www/html/src/test.ts:20:1

Description

  • After I have inserted some documents, the next insert into the same collection fails, because one metadata field is longer than the longest one from before.
  • This is because the metadata field length was calculated on the first insert based on the longest value, but is not updated on a reinsert.

System Info

@langchain/community v1.1.14
langchain v1.2.24
Node.js v24.13.0
MacOS 26

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions