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 18:45:25 UTC
[PR] TINKERPOP-3271 `subgraph()` throws a descriptive error for non-Edge input [tinkerpop]
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: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TINKERPOP-3271 `subgraph()` throws a descriptive error for non-Edge input [tinkerpop]
Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #3556:
URL: https://github.com/apache/tinkerpop/pull/3556#issuecomment-5064736131
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-3271 `subgraph()` throws a descriptive error for non-Edge input [tinkerpop]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3556:
URL: https://github.com/apache/tinkerpop/pull/3556#issuecomment-5062248129
## [Codecov](https://app.codecov.io/gh/apache/tinkerpop/pull/3556?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.00%. 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 ([`3014f98`](https://app.codecov.io/gh/apache/tinkerpop/commit/3014f983ceea92b1c43fcef63cc189d18fca8d67?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 34 commits behind head on 3.7-dev.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 3.7-dev #3556 +/- ##
=============================================
+ Coverage 75.49% 77.00% +1.50%
=============================================
Files 1092 28 -1064
Lines 67208 5331 -61877
Branches 7391 0 -7391
=============================================
- Hits 50742 4105 -46637
+ Misses 13837 1023 -12814
+ Partials 2629 203 -2426
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/tinkerpop/pull/3556?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-3271 `subgraph()` throws a descriptive error for non-Edge input [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on PR #3556:
URL: https://github.com/apache/tinkerpop/pull/3556#issuecomment-5064314278
VOTE +1
--
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-3271 `subgraph()` throws a descriptive error for non-Edge input [tinkerpop]
Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer merged PR #3556:
URL: https://github.com/apache/tinkerpop/pull/3556
--
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