spring-projects / spring-projects/spring-ai
Incompatible error in the "before" method of RetrievalAugmentationAdvisor
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Bug description
java.lang.IllegalStateException: Duplicate key Query[text=你是谁, history=[], context={}] (attempted merging values [[]] and [[]])
Environment
spring-ai: 1.1.2
jdk: 17
Steps to reproduce
If I customize the queryExpander, when executing the queryExpander to add historical queries to the List, if there are duplicates in my historical queries, an error will occur in the following line: Map<Query, List<List<Document>>> documentsForQuery = (Map)expandedQueries.stream().map((query) -> CompletableFuture.supplyAsync(() -> this.getDocumentsForQuery(query), this.taskExecutor)).toList().stream().map(CompletableFuture::join).collect(Collectors.toMap(Map.Entry::getKey, (entry) -> List.of((List)entry.getValue())));
Expected behavior
Add (v1, v2) -> v2 after toMap
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in RetrievalAugmentationAdvisor.before and inspect the expandedQueries-toMap pipeline shown in the report. Reproduce the case with duplicate historical queries, then verify that the advisor completes without the duplicate-key exception and that existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100