{"record":{"id":"a3ed493f12beffc2","repo":"spring-projects/spring-ai","slug":"documents-are-managed-via-data-source-not-direct","errorCode":null,"errorMessage":"Documents are managed via data source, not direct delete.","messagePattern":"Documents are managed via data source, not direct delete\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"vector-stores/spring-ai-bedrock-knowledgebase-store/src/main/java/org/springframework/ai/vectorstore/bedrockknowledgebase/BedrockKnowledgeBaseVectorStore.java","lineNumber":108,"sourceCode":"\n\t/**\n\t * Creates a new builder for BedrockKnowledgeBaseVectorStore.\n\t * @param client the Bedrock Agent Runtime client\n\t * @param knowledgeBaseId the ID of the Knowledge Base to query\n\t * @return a new builder instance\n\t */\n\tpublic static Builder builder(final BedrockAgentRuntimeClient client, final String knowledgeBaseId) {\n\t\treturn new Builder(client, knowledgeBaseId);\n\t}\n\n\t@Override\n\tpublic void add(final List<Document> documents) {\n\t\tthrow new UnsupportedOperationException(\"Documents are ingested via data source sync, not direct add.\");\n\t}\n\n\t@Override\n\tpublic void delete(final List<String> idList) {\n\t\tthrow new UnsupportedOperationException(\"Documents are managed via data source, not direct delete.\");\n\t}\n\n\t@Override\n\tpublic void delete(final Filter.Expression filterExpression) {\n\t\tthrow new UnsupportedOperationException(\"Documents are managed via data source, not direct delete.\");\n\t}\n\n\t@Override\n\tpublic List<Document> similaritySearch(final SearchRequest request) {\n\t\tAssert.notNull(request, \"SearchRequest must not be null\");\n\t\tAssert.hasText(request.getQuery(), \"Query must not be empty\");\n\n\t\tint topK = request.getTopK() > 0 ? request.getTopK() : this.defaultTopK;\n\t\tdouble threshold = request.getSimilarityThreshold() >= 0 ? request.getSimilarityThreshold()\n\t\t\t\t: this.defaultSimilarityThreshold;\n\n\t\tRetrievalFilter bedrockFilter = null;\n\t\tif (request.hasFilterExpression()) {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-bedrock-knowledgebase-store/src/main/java/org/springframework/ai/vectorstore/bedrockknowledgebase/BedrockKnowledgeBaseVectorStore.java#L90-L126","documentation":"BedrockKnowledgeBaseVectorStore.delete(List<String> idList) is intentionally unsupported: document lifecycle is owned by the external data source and synchronized via ingestion jobs, so ID-based deletes at the vector-store level cannot be executed. Calls throw UnsupportedOperationException.","triggerScenarios":"Calling store.delete(List.of(\"id1\",\"id2\")) on a BedrockKnowledgeBaseVectorStore, or generic cleanup/refresh code in a VectorStore abstraction that deletes by ID before re-upserting documents.","commonSituations":"Shared ingestion pipelines that do delete-then-add to keep stores in sync; migrating from ID-addressable stores (Redis, PgVector) where delete-by-id is standard; trying to remove individual documents without touching the source data.","solutions":["Delete the source objects in the data source (e.g. S3 keys) and run a new ingestion/sync job so the knowledge base reflects removals","Catch UnsupportedOperationException for delete-by-id on this store and implement data-source-driven cleanup instead","Restructure pipelines so Bedrock KB stores are refreshed via full data-source sync rather than incremental deletes","Add an explicit interface/capability check for delete support before invoking it on arbitrary VectorStore instances"],"exampleFix":"// before\nstore.delete(List.of(documentId)); // UnsupportedOperationException\n// after\ns3Client.deleteObject(b -> b.bucket(bucket).key(keyFor(documentId)));\nbedrockAgentClient.startIngestionJob(b -> b.knowledgeBaseId(kbId).dataSourceId(dsId));","handlingStrategy":"try-catch","validationCode":"if (store instanceof BedrockKnowledgeBaseVectorStore) { throw new IllegalStateException(\"Delete via data source + resync, not VectorStore.delete\"); }","typeGuard":"boolean supportsDeleteById(VectorStore store) { return !(store instanceof BedrockKnowledgeBaseVectorStore); }","tryCatchPattern":"try { store.delete(idList); } catch (UnsupportedOperationException e) { deleteFromDataSourceAndResync(idList); }","preventionTips":["Remove documents at the data source (S3) and re-run the ingestion job","Avoid delete-then-add refresh patterns for KB-backed stores","Check delete support before invoking it via the generic VectorStore interface","Keep data source keys mapped to document IDs so targeted removal is possible"],"tags":["bedrock","delete","unsupported-operation","aws"],"backgroundTag":"operation-not-supported","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}