GumpacG opened a new pull request, #3559:
URL: https://github.com/apache/tinkerpop/pull/3559
## Summary
`where(P)` expects a `String` scope key (e.g. `where(eq('a'))`). Given a
non-String
predicate value like `gt(5)`, `WherePredicateStep` cast it to `String`
unconditionally,
throwing a raw `ClassCastException` at step construction. This change
validates the
value first and throws a descriptive `IllegalArgumentException` pointing to
`is(P)` for
value comparisons. Backward-compatible diagnostics fix; valid queries are
unaffected.
## Before vs After
### Non-String (numeric) predicate value
```
__.values('v').where(gt(5))
```
* Before: `ClassCastException: class java.lang.Integer cannot be cast to
class java.lang.String`
* After: `IllegalArgumentException: where(P) requires a String scope key but
encountered Integer; use is(P) to compare values`
### Nested inside a parent `where(Traversal)`
```
g.V().hasLabel('X').where(__.values('v').where(gt(5)))
```
* Before: same `ClassCastException`, buried in a nested traversal
* After: same descriptive `IllegalArgumentException` pointing to `is(P)`
### Correct usage (unchanged)
```
g.V().as('a').out().where(eq('a')) // String scope key comparison
__.values('v').is(gt(5)) // value comparison via is(P)
```
* Before and after: works identically
## Changes
* `gremlin-core`: runtime `String` validation in
`WherePredicateStep.getSelectKey(...)`
* `gremlin-test`: negative tests added to the `WhereTest` suite (the
exception is thrown at step construction, so they pass across all engines)
* `CHANGELOG.asciidoc`: entry under 3.7.7
Assisted-by: Kiro: Claude Opus 4.8
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]