{"record":{"id":"584cbce6d9694b78","repo":"FlowiseAI/Flowise","slug":"error-inserting-data-json-stringify-insertresp","errorCode":null,"errorMessage":"Error inserting data: ${JSON.stringify(insertResp)}","messagePattern":"Error inserting data: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Milvus/Milvus.ts","lineNumber":487,"sourceCode":"            const resp = await this.client.createIndex({\n                collection_name: this.collectionName,\n                field_name: this.vectorField,\n                index_name: `myindex_${Date.now().toString()}`,\n                index_type: IndexType.AUTOINDEX,\n                metric_type: MetricType.L2\n            })\n            if (resp.error_code !== ErrorCode.SUCCESS) {\n                throw new Error(`Error creating index`)\n            }\n        }\n\n        const insertResp = await this.client.insert({\n            collection_name: this.collectionName,\n            fields_data: insertDatas\n        })\n\n        if (insertResp.status.error_code !== ErrorCode.SUCCESS) {\n            throw new Error(`Error inserting data: ${JSON.stringify(insertResp)}`)\n        }\n\n        await this.client.flushSync({ collection_names: [this.collectionName] })\n    }\n}\n\nmodule.exports = { nodeClass: Milvus_VectorStores }\n","sourceCodeStart":469,"sourceCodeEnd":495,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Milvus/Milvus.ts#L469-L495","documentation":"Thrown after `client.insert()` when the returned `insertResp.status.error_code` is not `SUCCESS`. The full insert response is JSON-stringified into the message, carrying the server-side reason (dimension mismatch, duplicate primary key, type coercion failure, etc.). This is the terminal insert failure for the Milvus upsert node.","triggerScenarios":"Inserting rows whose vector length differs from the schema; primary key already exists when not using upsert semantics; a scalar field's value type does not match the schema (e.g. string into an int64 column); collection not loaded; row count exceeds a segment limit.","commonSituations":"Embedding model changed (dimension mismatch); data type drift after a schema migration; duplicate IDs from a re-run without upsert; very large batch exceeding Milvus insert limits.","solutions":["Read `insertResp.status.reason` in the JSON payload to identify the precise server error.","Confirm every vector's dimension matches the collection's vector field dimension.","Ensure primary-key values are unique across the batch (or use upsert semantics).","Verify scalar field value types conform to the schema (cast/serialize before insert).","Reduce batch size if the error mentions row/segment limits."],"exampleFix":"// before\nconst insertResp = await this.client.insert({ collection_name: this.collectionName, fields_data: insertDatas })\nif (insertResp.status.error_code !== ErrorCode.SUCCESS) {\n    throw new Error(`Error inserting data: ${JSON.stringify(insertResp)}`)\n}\n// after — also log the offending rows for debugging\nif (insertResp.status.error_code !== ErrorCode.SUCCESS) {\n    console.error('Failed rows:', JSON.stringify(insertDatas).slice(0, 2000))\n    throw new Error(`Error inserting data (reason=${insertResp.status.reason}): ${JSON.stringify(insertResp)}`)\n}","handlingStrategy":"validation","validationCode":"function validateInsertRows(rows: InsertRow[], vectorDim: number, primaryField: string, autoId: boolean) {\n  rows.forEach((r, i) => {\n    const v = r[Object.keys(r).find(k => Array.isArray(r[k])) as string]\n    if (Array.isArray(v) && v.length !== vectorDim) throw new Error(`Row ${i} vector dim ${v.length} != ${vectorDim}`)\n    if (!autoId && r[primaryField] === undefined) throw new Error(`Row ${i} missing primary key '${primaryField}'`)\n  })\n}","typeGuard":"function isInsertSuccess(resp: any): boolean {\n  return resp?.status?.error_code === 0 || resp?.status?.error_code === 'Success'\n}","tryCatchPattern":"try {\n  const insertResp = await this.client.insert({ collection_name: this.collectionName, fields_data: insertDatas })\n  if (!isInsertSuccess(insertResp)) throw new Error(`insert failed: ${insertResp.status.reason}`)\n} catch (e) {\n  throw e instanceof Error ? e : new Error(`Milvus insert error: ${String(e)}`)\n}","preventionTips":["Verify vector dimensions match the schema before every batch.","Ensure primary keys are unique when not using upsert semantics.","Cast scalar values to their schema types before insert.","Reduce batch size on row/segment limit errors."],"tags":["milvus","insert","data-integrity","error-handling"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}