fix(core): reject vertex-property metadata during addV - #3178
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an incorrect traversal rewrite in HugePrimaryKeyStrategy where vertex-property metadata supplied via addV().property(key, value, metaKey, metaValue) could be folded into the vertex creation as ordinary vertex properties, despite HugeGraph not supporting meta-properties. It updates the optimization strategy to reject such metadata early and adds core tests to prevent regressions.
Changes:
- Reject vertex-property meta-properties during
HugePrimaryKeyStrategyfolding (fail before any write). - Add regression tests covering both
AddVertexStartStepand mid-traversalAddVertexSteppaths. - Register the new test class in the core test suite.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugePrimaryKeyStrategy.java | Rejects non-T.key/T.value parameters during property folding to prevent meta-property misinterpretation. |
| hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/PrimaryKeyStrategyCoreTest.java | Adds regression tests ensuring meta-properties are rejected (and normal folding still works). |
| hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java | Adds the new test class to the core suite so it runs in CI. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3178 +/- ##
============================================
+ Coverage 32.66% 37.18% +4.51%
- Complexity 5500 6384 +884
============================================
Files 789 791 +2
Lines 67703 67753 +50
Branches 8945 9027 +82
============================================
+ Hits 22117 25195 +3078
+ Misses 42984 39551 -3433
- Partials 2602 3007 +405 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
imbajin
left a comment
There was a problem hiding this comment.
The core fix is directionally correct, but the eager validation changes lazy branch behavior. I also left one readability note about wrapping well before the project's 120-column limit.
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Throwing from HugePrimaryKeyStrategy validated eagerly, so an unreachable coalesce()/choose() addV() fallback failed before its branch was picked. Fold only T.key/T.value into addV so PRIMARY_KEY labels keep their primary key, leave a metadata-bearing AddPropertyStep in place, and stop folding across it. HugeVertex.property() then rejects it, T.id case included. Signed-off-by: 1fanwang <1fannnw@gmail.com>
c673826 to
cf4f159
Compare
Purpose of the PR
addV().property(key, value, metaKey, metaValue)accepts unsupportedmeta-properties instead of rejecting the traversal.
Main Changes
Fold only
T.keyandT.valueintoaddV, then leave metadata-bearingAddPropertyStepinstances in the traversal. If the branch executes,HugeVertex.property()rejects the metadata. Unselectedcoalesce()andchoose()branches stay lazy, primary-key labels receive their key beforeaddVexecutes, andT.idkeeps its specific unsupported-ID error.Verifying these changes
Raw logs
Does this PR potentially affect the following parts?
Documentation Status
Doc - No Need