{"record":{"id":"5f9feb51f1449d5e","repo":"FlowiseAI/Flowise","slug":"e-5f9feb","errorCode":null,"errorMessage":"${e}","messagePattern":"\\$\\{e\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts","lineNumber":137,"sourceCode":"            const client = getOpenSearchClient(opensearchURL, user, password)\n\n            const flattenDocs = docs && docs.length ? flatten(docs) : []\n            const finalDocs = []\n            for (let i = 0; i < flattenDocs.length; i += 1) {\n                if (flattenDocs[i] && flattenDocs[i].pageContent) {\n                    finalDocs.push(new Document(flattenDocs[i]))\n                }\n            }\n\n            try {\n                await OpenSearchVectorStore.fromDocuments(finalDocs, embeddings, {\n                    client,\n                    indexName: indexName,\n                    vectorSearchOptions: getVectorSearchOptions(nodeData)\n                })\n                return { numAdded: finalDocs.length, addedDocs: finalDocs }\n            } catch (e) {\n                throw new Error(e)\n            }\n        }\n    }\n\n    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {\n        const embeddings = nodeData.inputs?.embeddings as Embeddings\n        const indexName = nodeData.inputs?.indexName as string\n        const output = nodeData.outputs?.output as string\n        const topK = nodeData.inputs?.topK as string\n        const k = topK ? parseFloat(topK) : 4\n        const credentialData = await getCredentialData(nodeData.credential ?? '', options)\n        const opensearchURL = getCredentialParam('openSearchUrl', credentialData, nodeData)\n        const user = getCredentialParam('user', credentialData, nodeData)\n        const password = getCredentialParam('password', credentialData, nodeData)\n\n        const client = getOpenSearchClient(opensearchURL, user, password)\n\n        const vectorStore = new OpenSearchVectorStore(embeddings, {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts#L119-L155","documentation":"Generic catch-all wrapping `OpenSearchVectorStore.fromDocuments` in the OpenSearch node's add path. Any failure (client construction, index creation, bulk indexing, auth) is re-thrown as `new Error(e)`, losing the original stack and collapsing the error into its string form.","triggerScenarios":"OpenSearch endpoint unreachable; wrong protocol/port in the URL; auth (basic/API key/AWS SigV4) misconfigured; vector dimension mismatch with the k-NN index mapping; bulk indexing rejected due to mapping conflicts.","commonSituations":"Self-hosted OpenSearch behind a different port than configured; AWS OpenSearch requiring SigV4 but only basic auth supplied; k-NN plugin not installed; embedding model changed dimension without re-creating the index mapping.","solutions":["Read the flattened message for the OpenSearch client error (auth, connection, mapping).","Verify the OpenSearch URL is reachable and the protocol/port are correct.","Confirm auth method matches the cluster requirement (basic / API key / SigV4).","Ensure the k-NN plugin is enabled and the index mapping's vector dimension matches the embedding output.","Re-wrap preserving the original error (see fix)."],"exampleFix":"// before\n} catch (e) {\n    throw new Error(e)\n}\n// after — preserve cause\n} catch (e) {\n    throw e instanceof Error ? e : new Error(String(e))\n}","handlingStrategy":"try-catch","validationCode":"// preflight: parse URL and ping\nconst u = new URL(openSearchUrl)\nif (!['http:', 'https:'].includes(u.protocol)) throw new Error('OpenSearch URL must be http(s)')\nconst ping = await fetch(`${u.origin}/_cluster/health`, { method: 'GET' })\nif (!ping.ok) throw new Error(`OpenSearch unreachable: ${ping.status}`)","typeGuard":"function isOpenSearchUrl(v: string): boolean {\n  try { const u = new URL(v); return ['http:', 'https:'].includes(u.protocol) } catch { return false }\n}","tryCatchPattern":"try {\n  await OpenSearchVectorStore.fromDocuments(finalDocs, embeddings, { client, indexName })\n} catch (e) {\n  throw e instanceof Error ? e : new Error(`OpenSearch fromDocuments failed: ${String(e)}`)\n}","preventionTips":["Confirm protocol/port/auth match the cluster requirement.","Ensure the k-NN plugin is installed and the mapping dimension matches.","Avoid `throw new Error(e)` — rethrow the original.","Use SigV4 signing for AWS OpenSearch."],"tags":["opensearch","error-handling","connection","stack-trace"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}