Skip to content

TINKERPOP-3270 where(P) throws a descriptive error for non-String scope keys#3559

Merged
Cole-Greer merged 2 commits into
apache:3.7-devfrom
GumpacG:wherep-err
Jul 24, 2026
Merged

TINKERPOP-3270 where(P) throws a descriptive error for non-String scope keys#3559
Cole-Greer merged 2 commits into
apache:3.7-devfrom
GumpacG:wherep-err

Conversation

@GumpacG

@GumpacG GumpacG commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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

@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.86957% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.52%. Comparing base (4722890) to head (207b390).
⚠️ Report is 41 commits behind head on 3.7-dev.

Files with missing lines Patch % Lines
...emlin/process/traversal/step/filter/WhereTest.java 50.00% 8 Missing ⚠️
...cess/traversal/step/filter/WherePredicateStep.java 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             3.7-dev    #3559      +/-   ##
=============================================
+ Coverage      75.49%   75.52%   +0.02%     
- Complexity     13161    13183      +22     
=============================================
  Files           1092     1093       +1     
  Lines          67208    67249      +41     
  Branches        7391     7397       +6     
=============================================
+ Hits           50742    50792      +50     
  Misses         13837    13837              
+ Partials        2629     2620       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xiazcy

xiazcy commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

VOTE +1 pending comment resolution

@Cole-Greer

Copy link
Copy Markdown
Contributor

VOTE +1, merging as CTR

@Cole-Greer
Cole-Greer merged commit 7e1820c into apache:3.7-dev Jul 24, 2026
33 checks passed
@GumpacG
GumpacG deleted the wherep-err branch July 24, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants