You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "GumpacG (via GitHub)" <gi...@apache.org> on 2026/07/23 21:16:48 UTC
[PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #3559:
URL: https://github.com/apache/tinkerpop/pull/3559#issuecomment-5064845319
VOTE +1, merging as CTR
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on code in PR #3559:
URL: https://github.com/apache/tinkerpop/pull/3559#discussion_r3641938627
##########
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java:
##########
@@ -552,5 +583,19 @@ public Traversal<Vertex, String> get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXa
public Traversal<Vertex, String> get_g_VX3X_asXaX_in_out_asXbX_whereXa_eqXbXX_byXageX_name(final Object v3Id) {
return g.V(v3Id).as("a").in().out().as("b").where("a", eq("b")).by("age").values("name");
}
+
+ @Override
+ public Traversal<Vertex, Integer> get_g_V_valuesXageX_whereXgtX5XX() {
+ // gt(5) yields a P whose value is an Integer rather than a String scope key; the cast mimics the
+ // erased P<String> that reaches where(P) via raw types, bytecode, or deserialization
+ final P<String> nonStringKeyPredicate = (P<String>) (P) gt(5);
Review Comment:
Curious, why the double cast for (P) here? Doesn't `(P) gt(5)` gets you the integer form that you wanted? Or am I misreading the test?
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3559:
URL: https://github.com/apache/tinkerpop/pull/3559#issuecomment-5063721724
## [Codecov](https://app.codecov.io/gh/apache/tinkerpop/pull/3559?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 77.06%. Comparing base ([`4722890`](https://app.codecov.io/gh/apache/tinkerpop/commit/4722890ed831ba4f71c3916b5e6eafcf85439345?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`b6ddb27`](https://app.codecov.io/gh/apache/tinkerpop/commit/b6ddb2770d7404258e8412f564bb69e644442216?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 36 commits behind head on 3.7-dev.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 3.7-dev #3559 +/- ##
=============================================
+ Coverage 75.49% 77.06% +1.56%
=============================================
Files 1092 28 -1064
Lines 67208 5332 -61876
Branches 7391 0 -7391
=============================================
- Hits 50742 4109 -46633
+ Misses 13837 1020 -12817
+ Partials 2629 203 -2426
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/tinkerpop/pull/3559?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on code in PR #3559:
URL: https://github.com/apache/tinkerpop/pull/3559#discussion_r3641938627
##########
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java:
##########
@@ -552,5 +583,19 @@ public Traversal<Vertex, String> get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXa
public Traversal<Vertex, String> get_g_VX3X_asXaX_in_out_asXbX_whereXa_eqXbXX_byXageX_name(final Object v3Id) {
return g.V(v3Id).as("a").in().out().as("b").where("a", eq("b")).by("age").values("name");
}
+
+ @Override
+ public Traversal<Vertex, Integer> get_g_V_valuesXageX_whereXgtX5XX() {
+ // gt(5) yields a P whose value is an Integer rather than a String scope key; the cast mimics the
+ // erased P<String> that reaches where(P) via raw types, bytecode, or deserialization
+ final P<String> nonStringKeyPredicate = (P<String>) (P) gt(5);
Review Comment:
Curious, why the double cast for (P) here?
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
Posted by "GumpacG (via GitHub)" <gi...@apache.org>.
GumpacG commented on code in PR #3559:
URL: https://github.com/apache/tinkerpop/pull/3559#discussion_r3641972404
##########
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java:
##########
@@ -552,5 +583,19 @@ public Traversal<Vertex, String> get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXa
public Traversal<Vertex, String> get_g_VX3X_asXaX_in_out_asXbX_whereXa_eqXbXX_byXageX_name(final Object v3Id) {
return g.V(v3Id).as("a").in().out().as("b").where("a", eq("b")).by("age").values("name");
}
+
+ @Override
+ public Traversal<Vertex, Integer> get_g_V_valuesXageX_whereXgtX5XX() {
+ // gt(5) yields a P whose value is an Integer rather than a String scope key; the cast mimics the
+ // erased P<String> that reaches where(P) via raw types, bytecode, or deserialization
+ final P<String> nonStringKeyPredicate = (P<String>) (P) gt(5);
Review Comment:
Addressed. It was redundant and removed.
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer merged PR #3559:
URL: https://github.com/apache/tinkerpop/pull/3559
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3270 `where(P)` throws a descriptive error for non-String scope keys [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on PR #3559:
URL: https://github.com/apache/tinkerpop/pull/3559#issuecomment-5064461693
VOTE +1 pending comment resolution
--
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org