{"record":{"id":"18e08e43d2cbf206","repo":"FlowiseAI/Flowise","slug":"failed-to-delete-documents-from-kendra-error","errorCode":null,"errorMessage":"Failed to delete documents from Kendra: ${error}","messagePattern":"Failed to delete documents from Kendra: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Kendra/Kendra.ts","lineNumber":203,"sourceCode":"            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) {\n                    const batch = ids.slice(i, i + batchSize)\n                    const command = new BatchDeleteDocumentCommand({\n                        IndexId: indexId,\n                        DocumentIdList: batch\n                    })\n                    await client.send(command)\n                }\n            } catch (error) {\n                throw new Error(`Failed to delete documents from Kendra: ${error}`)\n            }\n        }\n    }\n\n    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {\n        const indexId = nodeData.inputs?.indexId as string\n        const region = nodeData.inputs?.region as string\n        const topK = nodeData.inputs?.topK as string\n        const attributeFilter = nodeData.inputs?.attributeFilter\n        const isFileUploadEnabled = nodeData.inputs?.fileUpload as boolean\n\n        const credentialConfig = await getAWSCredentialConfig(nodeData, options, region)\n        let clientOptions: Partial<KendraClientConfig> = {}\n\n        if (credentialConfig.credentials) {\n            clientOptions.credentials = credentialConfig.credentials\n        }\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Kendra/Kendra.ts#L185-L221","documentation":"Catch-all around the Kendra batch delete loop (BatchDeleteDocumentCommand, 10 ids per batch). Wraps any KendraClient.send failure into a string Error.","triggerScenarios":"Delete ids from a Kendra index. Fails on auth/permission errors, wrong indexId, throttling, or Kendra service errors during batch delete.","commonSituations":"Missing kendra:BatchDeleteDocument permission, index in wrong region, indexId typo, or transient AWS service error.","solutions":["Confirm the IAM principal has kendra:BatchDeleteDocument on the index.","Verify indexId and region match the index used for upsert.","Retry transient AWS errors with exponential backoff.","Rethrow the original error to retain the AWS SDK's retryable flag."],"exampleFix":"// before\n} catch (error) {\n    throw new Error(`Failed to delete documents from Kendra: ${error}`)\n}\n\n// after\n} catch (error) {\n    console.error('Kendra delete failed', error)\n    throw error\n}","handlingStrategy":"retry","validationCode":"const idx = await client.send(new DescribeIndexCommand({ Id: indexId }))\nif (idx.Status !== 'ACTIVE') throw new Error(`Index ${indexId} not ACTIVE (${idx.Status})`)\nif (!ids.length) return // nothing to delete","typeGuard":"function isRetryableAwsError(e: unknown): boolean {\n  return typeof e === 'object' && e !== null\n    && ['ThrottlingException', 'ServiceUnavailableException', 'RequestLimitExceeded'].includes((e as any).name)\n}","tryCatchPattern":"for (let attempt = 0; attempt < 3; attempt++) {\n  try { await deleteBatch(client, indexId, ids); break }\n  catch (e) {\n    if (isRetryableAwsError(e) && attempt < 2) { await backoff(attempt); continue }\n    throw e\n  }\n}","preventionTips":["Grant kendra:BatchDeleteDocument to the IAM principal.","Make delete idempotent — deleting a non-existent id should not throw.","Retry throttling errors with exponential backoff."],"tags":["kendra","aws","delete","error-wrapping"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}