{"record":{"id":"81ff0fbc5b680789","repo":"n8n-io/n8n","slug":"collection-must-be-a-string","errorCode":null,"errorMessage":"Collection must be a string","messagePattern":"Collection must be a string","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts","lineNumber":397,"sourceCode":"\t\t\t\t\tthrow new NodeApiError(this.getNode(), {\n\t\t\t\t\t\tmessage: `Failed to list ChromaDB collections: ${errorMessage}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\tretrieveFields,\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\tconst collection = context.getNodeParameter('chromaCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t});\n\n\t\tif (typeof collection !== 'string') {\n\t\t\tthrow new NodeOperationError(context.getNode(), 'Collection must be a string');\n\t\t}\n\n\t\ttry {\n\t\t\tconst config = await getChromaLibConfig(context, collection, itemIndex);\n\t\t\treturn await ExtendedChroma.fromExistingCollection(embeddings, config);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : 'Unknown error';\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error connecting to ChromaDB: ${message}`, {\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t},\n\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\tconst collection = context.getNodeParameter('chromaCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t});\n","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts#L379-L415","documentation":"Thrown as a NodeOperationError in `getVectorStoreClient` after extracting the `chromaCollection` parameter with `extractValue: true`. The parameter is expected to be a string (the collection name) but came back as something else (object, number, array, or the RLC's raw `{ mode, value }` envelope when extraction did not unwrap it).","triggerScenarios":"The collection RLC is in 'name' mode but its stored value is not a string; a workflow JSON migrated from an older typeVersion stored the collection as an object; an expression resolved to a non-string value at execution time.","commonSituations":"Workflow imported from a different n8n version where the parameter shape changed; expression like `={{ $json.someObject }}` returning an object instead of a string; typeVersion downgrade where the RLC envelope isn't unwrapped.","solutions":["Re-open the node and pick the collection from the dropdown (or type the name) so the parameter is stored as a plain string.","If using an expression, ensure it resolves to a string (wrap with `String(...)` or `?.toString()`).","Check the node's `typeVersion` matches the workflow's expected version; upgrade the node if prompted.","Inspect the saved workflow JSON to confirm `chromaCollection` is a string, not an object."],"exampleFix":"// before\nconst collection = context.getNodeParameter('chromaCollection', itemIndex, '', { extractValue: true });\nif (typeof collection !== 'string') {\n  throw new NodeOperationError(context.getNode(), 'Collection must be a string');\n}\n\n// after: coerce common envelope shapes before rejecting\nconst raw = context.getNodeParameter('chromaCollection', itemIndex, '', { extractValue: true });\nconst collection =\n  typeof raw === 'string' ? raw\n  : typeof raw === 'object' && raw && typeof (raw as { value?: unknown }).value === 'string'\n    ? (raw as { value: string }).value\n    : undefined;\nif (!collection) {\n  throw new NodeOperationError(context.getNode(), 'Collection must be a string', {\n    description: `Received ${typeof raw}: ${JSON.stringify(raw)}`,\n    itemIndex,\n  });\n}","handlingStrategy":"type-guard","validationCode":"// Resolve the parameter to a string, coercing common envelope shapes, before using it.\nfunction resolveCollectionName(context: IExecuteFunctions, itemIndex: number): string {\n  const raw = context.getNodeParameter('chromaCollection', itemIndex, '', { extractValue: true });\n  if (typeof raw === 'string') return raw;\n  if (raw && typeof raw === 'object' && typeof (raw as { value?: unknown }).value === 'string') {\n    return (raw as { value: string }).value;\n  }\n  throw new NodeOperationError(context.getNode(), 'Collection must be a string', {\n    itemIndex, description: `Received ${typeof raw}: ${JSON.stringify(raw)}`,\n  });\n}","typeGuard":"function isCollectionName(value: unknown): value is string {\n  return typeof value === 'string' && value.trim().length > 0;\n}","tryCatchPattern":"const raw = context.getNodeParameter('chromaCollection', itemIndex, '', { extractValue: true });\nif (!isCollectionName(raw)) {\n  throw new NodeOperationError(context.getNode(), 'Collection must be a string', { itemIndex });\n}\n// proceed with raw","preventionTips":["Always pick the collection from the dropdown so it is stored as a string.","Wrap expression results with String(...) when binding to this field.","Upgrade node typeVersion after a parameter-shape change."],"tags":["chromadb","vector-store","type-validation","parameter","node-operation-error","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}