GumpacG opened a new pull request, #3556:
URL: https://github.com/apache/tinkerpop/pull/3556

   ## Summary
   
   `subgraph()` produces an edge-induced subgraph and must be called at an edge 
step.
   When the traversal instead feeds it a non-Edge value, `SubgraphStep` passed 
that
   value straight into an `Edge`-typed method, producing a raw 
`ClassCastException`
   with no indication of what went wrong.
   
   This change validates the traverser value at runtime and throws a descriptive
   `IllegalStateException` naming the required `Edge` input, consistent with the
   existing pattern in `AddPropertyStep` and `AddEdgeStep`. Valid queries are
   unaffected; only the failure message for already-invalid queries changes.
   
   This is a backward-compatible diagnostics fix (runtime validation only, no 
API or
   generics change).
   
   ## Before vs After
   
   ### Non-edge (primitive) input
   ```groovy
   g.inject(1).subgraph('sg').cap('sg').iterate()
   ```
   - Before: `ClassCastException: class java.lang.Integer cannot be cast to 
class ...Edge`
   - After: `IllegalStateException: subgraph() requires Edge input but 
encountered Integer; use an edge step such as outE(), inE(), or bothE()`
   
   ### Vertex input
   ```groovy
   g.addV().subgraph('sg').cap('sg').iterate()
   ```
   - Before: `ClassCastException: class ...TinkerVertex cannot be cast to class 
...Edge`
   - After: `IllegalStateException: subgraph() requires Edge input but 
encountered TinkerVertex; use an edge step such as outE(), inE(), or bothE()`
   
   ### Correct usage (unchanged)
   ```groovy
   g.V().has('v',1).outE('X').subgraph('sg').cap('sg')  // edges in -> builds 
subgraph
   ```
   - Before and after: works identically
   
   ## Changes
   - `gremlin-core`: runtime `Edge` validation in `SubgraphStep.sideEffect(...)`
   - `gremlin-test`: two negative tests added to the `SubgraphTest` suite
   - `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]

Reply via email to