contrueCT opened a new issue, #3165: URL: https://github.com/apache/hugegraph/issues/3165
### Bug Type (问题类型) gremlin (unexpected result) ### Before submit - [x] I searched the existing issues and did not find the same problem. ### Environment (环境信息) - HugeGraph Server: current `apache/hugegraph` `master` at [`431f6e6b`](https://github.com/apache/hugegraph/commit/431f6e6b431014feb5b50d27ea67180b4610f10b) - TinkerPop: 3.5.1 - Backend: backend-independent; the incorrect rewrite happens in a traversal strategy before the vertex is written ### Expected and actual behavior (期望与实际表现) `HugePrimaryKeyStrategy` folds a single-cardinality `AddPropertyStep` immediately following `addV()` into the vertex-creation step. For this traversal: ```groovy g.addV("person"). property("name", "marko", "country", "cn") ``` TinkerPop treats `country=cn` as a meta-property attached to the `name` vertex property. It does not treat `country` as a sibling property of the vertex. HugeGraph currently reports `supportsMetaProperties() == false`, and `HugeVertex.property(...)` explicitly throws `VertexProperty.Exceptions.metaPropertiesNotSupported()` when meta-properties are passed. The expected behavior is therefore an explicit rejection. The optimization changes that behavior. `HugePrimaryKeyStrategy` copies every `AddPropertyStep` parameter other than `T.key` and `T.value` into the `addV()` configuration, then removes the original `AddPropertyStep`. If `country` is also a valid schema property, HugeGraph can silently create an ordinary vertex property `country=cn` instead of rejecting the unsupported meta-property. This is a data-semantics problem because an unsupported construct is accepted with a different meaning. ### Minimal reproduction Create a schema in which both keys are valid ordinary vertex properties: ```groovy schema = graph.schema() schema.propertyKey("name").asText().create() schema.propertyKey("country").asText().create() schema.vertexLabel("person"). properties("name", "country"). primaryKeys("name"). create() ``` Run the traversal and inspect the resulting vertex: ```groovy g.addV("person"). property("name", "marko", "country", "cn"). iterate() g.V().hasLabel("person").has("name", "marko").valueMap(true) ``` Expected: - The write is rejected with `metaPropertiesNotSupported()`. - `country=cn` is never stored as an ordinary vertex property. Actual on the affected strategy path: - The `AddPropertyStep` is removed. - `country=cn` is folded into the vertex-creation step as an ordinary vertex property. A strategy-level reproduction shows the rewritten traversal as: ```text AddVertexStartStep({country=[cn], label=[person], name=[marko]}) ``` ### Source analysis - [TinkerPop 3.5.1 `AddPropertyStep`](https://github.com/apache/tinkerpop/blob/3.5.1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java#L93-L99) separates `T.key` and `T.value` from the remaining vertex-property key/value pairs, then passes the remaining pairs to `Vertex.property(...)` as meta-properties. - [HugeGraph declares that meta-properties are unsupported](https://github.com/apache/hugegraph/blob/431f6e6b431014feb5b50d27ea67180b4610f10b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeFeatures.java#L261-L265). - [`HugeVertex.property(...)` rejects them](https://github.com/apache/hugegraph/blob/431f6e6b431014feb5b50d27ea67180b4610f10b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeVertex.java#L436-L444). - [`HugePrimaryKeyStrategy` changes the remaining pairs into `addV()` parameters](https://github.com/apache/hugegraph/blob/431f6e6b431014feb5b50d27ea67180b4610f10b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugePrimaryKeyStrategy.java#L75-L98). The strategy was introduced in [`4b74ab6c`](https://github.com/apache/hugegraph/commit/4b74ab6cec4a8357dd6a8feef4e3c9ea616fa52f) in March 2023. The same behavior is still present on the current public `master` branch. It was noticed while reviewing a TinkerPop 3.8.1 adaptation, but it is not introduced by that upgrade. ### Suggested fix and acceptance criteria When an `AddPropertyStep` contains vertex-property metadata, `HugePrimaryKeyStrategy` should not fold that step into `addV()`. Leaving the step in place preserves the existing explicit rejection from `HugeVertex.property(...)`. A regression test should verify that: 1. The traversal above throws the unsupported-meta-property exception. 2. The metadata key is never written as an ordinary vertex property. 3. Normal `addV().property(key, value)` folding still works. 4. Both `AddVertexStartStep` and mid-traversal `AddVertexStep` paths preserve the same behavior. -- 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]
