Skip to content

[Bug] HugePrimaryKeyStrategy silently converts vertex-property metadata into vertex properties #3165

Description

@contrueCT

Bug Type (问题类型)

gremlin (unexpected result)

Before submit

  • I searched the existing issues and did not find the same problem.

Environment (环境信息)

  • HugeGraph Server: current apache/hugegraph master at 431f6e6b
  • 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:

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:

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:

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:

AddVertexStartStep({country=[cn], label=[person], name=[marko]})

Source analysis

The strategy was introduced in 4b74ab6c 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggremlinTinkerPop gremlin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions