{"record":{"id":"85aa79e4d7f43b67","repo":"FlowiseAI/Flowise","slug":"failed-to-index-documents-to-kendra-error","errorCode":null,"errorMessage":"Failed to index documents to Kendra: ${error}","messagePattern":"Failed to index documents to Kendra: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Kendra/Kendra.ts","lineNumber":176,"sourceCode":"                    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\n            }\n            const client = new KendraClient(clientConfig)\n\n            try {\n                // Kendra has a limit of 10 documents per batch delete\n                const batchSize = 10\n                for (let i = 0; i < ids.length; i += batchSize) {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Kendra/Kendra.ts#L158-L194","documentation":"Outer catch-all in the Kendra upsert path that wraps the inner 'Failed to index some documents' error (and any other error in batching/sending) into 'Failed to index documents to Kendra'. This double-wrapping obscures the original FailedDocuments detail.","triggerScenarios":"Any throw inside the try — the inner FailedDocuments throw, a KendraClient.send transport error, or a credential error — surfaces here as a wrapped string.","commonSituations":"AWS credentials invalid/missing, region wrong, index ARN/Id wrong, throttling, or the inner partial-failure throw propagating.","solutions":["Inspect the wrapped message to see the inner cause (often the FailedDocuments JSON).","Verify AWS credentials, region, and indexId are correct and the client has kendra:BatchPutDocument permission.","Distinguish transport errors from partial failures: rethrow the original error to keep type information."],"exampleFix":"// before\n} catch (error) {\n    throw new Error(`Failed to index documents to Kendra: ${error}`)\n}\n\n// after\n} catch (error) {\n    console.error('Kendra index failed', error)\n    throw error\n}","handlingStrategy":"try-catch","validationCode":"const sts = await client.send(new GetCallerIdentityCommand({}))\n// confirm permission\nawait client.send(new DescribeIndexCommand({ Id: indexId }))\n// confirms kendra:DescribeIndex and that indexId exists in this region","typeGuard":"function isKendraError(e: unknown): e is { name: string; $metadata: { httpStatusCode: number } } {\n  return typeof e === 'object' && e !== null && typeof (e as any).name === 'string' && /^.+Error$/.test((e as any).name)\n}","tryCatchPattern":"try {\n  await indexToKendra(client, indexId, kendraDocuments)\n} catch (e) {\n  // unwrap the inner FailedDocuments detail if present\n  const inner = String(e).includes('FailedDocuments') ? String(e) : `Kendra index failed: ${e}`\n  throw new Error(inner, { cause: e })\n}","preventionTips":["Grant kendra:BatchPutDocument and kendra:DescribeIndex to the IAM principal.","Confirm region and indexId match the indexed index.","Unwrap inner errors instead of double-wrapping them."],"tags":["kendra","aws","error-wrapping","indexing"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}