spring-projects / spring-projects/spring-ai
`FilterExpressionTextParser` fails to parse expressions whose first key starts with the letters `where`
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
FilterExpressionTextParser prepends the compulsory WHERE keyword only when the expression does not already start with it, but the check is a plain string prefix test:
if (!textFilterExpression.toUpperCase(Locale.ROOT).startsWith(WHERE_PREFIX)) {
A metadata key that merely starts with the letters where — such as whereabouts or where_clause — satisfies the prefix check, so WHERE is never prepended. The lexer then tokenizes the identifier as IDENTIFIER rather than the WHERE token required by the grammar rule where : WHERE booleanExpression EOF, and parsing fails.
Environment
- Spring AI
2.0.2-SNAPSHOT,mainat0933bd0 - Module:
spring-ai-vector-store - Class:
org.springframework.ai.vectorstore.filter.FilterExpressionTextParser
Steps to reproduce
new FilterExpressionTextParser().parse("whereabouts == 'BG'");
fails with:
FilterExpressionTextParser$FilterExpressionParseException
Caused by: org.antlr.v4.runtime.InputMismatchException
at org.springframework.ai.vectorstore.filter.antlr4.FiltersParser.where(FiltersParser.java:186)
while e.g. parse("country == 'BG'") works.
Expected behavior
whereabouts == 'BG' parses to EQ(Key("whereabouts"), Value("BG")) like any other key. The prefix check should only match the standalone WHERE keyword (e.g. ^\s*where\b, case-insensitive), not any identifier that happens to start with those letters.
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 the spring-ai-vector-store module at org.springframework.ai.vectorstore.filter.FilterExpressionTextParser and reproduce the failure with whereabouts == 'BG'. Check the existing WHERE-prefix handling and its interaction with the FiltersParser grammar. Done means keys beginning with where parse successfully while the standalone WHERE keyword continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100