{"record":{"id":"2e77de0ad7c42e06","repo":"FlowiseAI/Flowise","slug":"failed-to-index-some-documents-json-stringify-r","errorCode":null,"errorMessage":"Failed to index some documents: ${JSON.stringify(response.FailedDocuments)}","messagePattern":"Failed to index some documents: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Kendra/Kendra.ts","lineNumber":169,"sourceCode":"                }\n            }\n\n            try {\n                if (kendraDocuments.length > 0) {\n                    // Kendra has a limit of 10 documents per batch\n                    const batchSize = 10\n                    for (let i = 0; i < kendraDocuments.length; i += batchSize) {\n                        const batch = kendraDocuments.slice(i, i + batchSize)\n                        const command = new BatchPutDocumentCommand({\n                            IndexId: indexId,\n                            Documents: batch\n                        })\n\n                        const response = await client.send(command)\n\n                        if (response.FailedDocuments && response.FailedDocuments.length > 0) {\n                            console.error('Failed documents:', response.FailedDocuments)\n                            throw new Error(`Failed to index some documents: ${JSON.stringify(response.FailedDocuments)}`)\n                        }\n                    }\n                }\n\n                return { numAdded: finalDocs.length, addedDocs: finalDocs }\n            } catch (error) {\n                throw new Error(`Failed to index documents to Kendra: ${error}`)\n            }\n        },\n\n        async delete(nodeData: INodeData, ids: string[], options: ICommonObject): Promise<void> {\n            const indexId = nodeData.inputs?.indexId as string\n            const region = nodeData.inputs?.region as string\n\n            const credentialConfig = await getAWSCredentialConfig(nodeData, options, region)\n            let clientConfig: KendraClientConfig = { region }\n            if (credentialConfig.credentials) {\n                clientConfig.credentials = credentialConfig.credentials","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Kendra/Kendra.ts#L151-L187","documentation":"AWS Kendra's BatchPutDocumentCommand returned a non-empty FailedDocuments list. Each failed document has an Id, ErrorCode, and ErrorMessage; the error stringifies the whole list. Some documents in the batch were not indexed.","triggerScenarios":"Batch upsert (10 docs per batch) into a Kendra index. Fails when Kendra reports per-document failures such as DOCUMENT_MISSING_TITLE, BAD_FILTER, ACCESS_DENIED, or quota exceeded.","commonSituations":"Document missing required attributes (Title/ContentType), access control misconfigured, oversized documents, or Kendra index not in ACTIVE state.","solutions":["Parse response.FailedDocuments to identify which Ids failed and their ErrorCodes; fix and retry only those.","Ensure each Kendra document has required fields (Title, ContentType) and valid attributes.","Confirm the index is ACTIVE and not being modified.","Log FailedDocuments before throwing so partial failures are visible."],"exampleFix":"// before\nthrow new Error(`Failed to index some documents: ${JSON.stringify(response.FailedDocuments)}`)\n\n// after\nconsole.error('Failed documents:', response.FailedDocuments)\nconst failedIds = response.FailedDocuments.map(d => d.Id)\nthrow new Error(`Failed to index ${failedIds.length} doc(s): ${failedIds.join(',')}`, { cause: response.FailedDocuments })","handlingStrategy":"try-catch","validationCode":"function validateKendraDocs(docs: KendraDocument[]) {\n  for (const d of docs) {\n    if (!d.Title) throw new Error(`Document ${d.Id} missing Title`)\n    if (!d.ContentType) throw new Error(`Document ${d.Id} missing ContentType`)\n  }\n}\nvalidateKendraDocs(kendraDocuments)\n// confirm index ACTIVE\nconst idx = await client.send(new DescribeIndexCommand({ Id: indexId }))\nif (idx.Status !== 'ACTIVE') throw new Error(`Index ${indexId} is ${idx.Status}`)","typeGuard":"function hasFailedDocuments(r: unknown): r is { FailedDocuments: { Id: string; ErrorCode: string; ErrorMessage?: string }[] } {\n  return typeof r === 'object' && r !== null && Array.isArray((r as any).FailedDocuments) && (r as any).FailedDocuments.length > 0\n}","tryCatchPattern":"const response = await client.send(command)\nif (hasFailedDocuments(response)) {\n  const retryable = response.FailedDocuments.filter(d => /quota|throttl/i.test(d.ErrorCode))\n  if (retryable.length) { await backoff(); /* retry those */ }\n  else throw new Error(`Kendra rejected docs: ${response.FailedDocuments.map(d => d.Id).join(',')}`)\n}","preventionTips":["Pre-validate each Kendra document's required fields before batching.","Confirm the index is ACTIVE before upsert.","Log FailedDocuments so partial failures are diagnosable."],"tags":["kendra","aws","batch","indexing"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}