FlowiseAI/Flowise · error · Error
The field "${field}" is not provided in documents[${index}].
Error message
The field "${field}" is not provided in documents[${index}].metadata. What it means
Thrown during Milvus upsert when iterating the collection's declared fields and encountering a non-primary/text/vector field whose value is missing from the current document's `metadata`. Milvus requires every schema field to have a value on insert, so any declared metadata column without a corresponding `doc.metadata[field]` entry aborts the batch.
Source
Thrown at packages/components/nodes/vectorstores/Milvus/Milvus.ts:451
case this.primaryField:
if (!this.autoId) {
if (doc.metadata[this.primaryField] === undefined) {
throw new Error(
`The Collection's primaryField is configured with autoId=false, thus its value must be provided through metadata.`
)
}
data[field] = doc.metadata[this.primaryField]
}
break
case this.textField:
data[field] = doc.pageContent
break
case this.vectorField:
data[field] = vec
break
default: // metadata fields
if (doc.metadata[field] === undefined) {
throw new Error(`The field "${field}" is not provided in documents[${index}].metadata.`)
} else if (typeof doc.metadata[field] === 'object') {
data[field] = JSON.stringify(doc.metadata[field])
} else {
data[field] = doc.metadata[field]
}
break
}
})
insertDatas.push(data)
}
const descIndexResp = await this.client.describeIndex({
collection_name: this.collectionName
})
if (descIndexResp.status.error_code === ErrorCode.IndexNotExist) {
const resp = await this.client.createIndex({View on GitHub (pinned to abe4a8601a)
Solutions
- Ensure every document's `metadata` contains a value for every non-primary/text/vector field declared in the collection schema.
- Backfill missing fields with a sensible default (e.g. empty string) before insert.
- Drop the extra scalar field from the Milvus schema if it is not consistently populated.
- Log `this.fields` vs the document's metadata keys before insert to surface gaps early.
Example fix
// before — gaps in metadata cause per-document abort
for (const doc of documents) await store.addDocuments([doc])
// after — backfill all declared fields with defaults
const requiredFields = store.fields.filter(f => ![store.primaryField, store.textField, store.vectorField].includes(f))
const safeDocs = documents.map(doc => {
const md = { ...doc.metadata }
for (const f of requiredFields) if (md[f] === undefined) md[f] = ''
return new Document({ pageContent: doc.pageContent, metadata: md })
}) Defensive patterns
Strategy: validation
Validate before calling
function validateMetadataFields(docs: Document[], requiredFields: string[], reserved: string[]) {
const need = requiredFields.filter(f => !reserved.includes(f))
for (let i = 0; i < docs.length; i++) {
for (const f of need) {
if (docs[i].metadata?.[f] === undefined) {
throw new Error(`documents[${i}].metadata missing field '${f}'`)
}
}
}
} Type guard
function documentCoversSchema(doc: Document, schemaFields: string[]): boolean {
return schemaFields.every(f => doc.metadata?.[f] !== undefined)
} Try / catch
try {
validateMetadataFields(documents, this.fields, [this.primaryField, this.textField, this.vectorField])
await store.addVectors(vectors, documents)
} catch (e) {
throw e instanceof Error ? e : new Error(String(e))
} Prevention
- Keep document metadata in sync with the collection schema; backfill new scalar columns with defaults.
- Validate every document covers all declared schema fields before batch insert.
- Use a single loader pipeline that guarantees required metadata keys.
- Log field-level gaps before they reach Milvus.
When it happens
Trigger: The Milvus collection schema declares extra scalar columns (e.g. `source`, `category`, `timestamp`) but one or more ingested `Document` objects omit that key in `metadata`. The check is `doc.metadata[field] === undefined`, so `null` also trips a later path.
Common situations: Schema evolved (new column added) but upstream documents were not updated; documents come from heterogeneous loaders where some set the field and others do not; field name casing mismatch between schema and metadata.
Related errors
- The Collection's primaryField is configured with autoId=fals
- Invalid JSON in StructuredOutputParser: ${exception}
- Error parsing Zod Schema: ${exception}
- Number of keys (${keyStrings.length}) does not match number
- Number of keys (${keyStrings.length}) does not match number
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/634a39266f020669.
Report an issue: GitHub.