Skip to content

TINKERPOP-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified - #3715

Open
paul-lartigau wants to merge 1 commit into
apache:3.8-devfrom
paul-lartigau:TINKERPOP-3294
Open

paul-lartigau wants to merge 1 commit into
apache:3.8-devfrom
paul-lartigau:TINKERPOP-3294

Conversation

@paul-lartigau

Copy link
Copy Markdown

https://issues.apache.org/jira/browse/TINKERPOP-3294

captureRemovedProperty() was checking the step's cardinality field, which is null when property() is called without an explicit cardinality. The old value passed to vertexPropertyChanged() was then always empty, even though the property itself was written with the graph's default cardinality.

The effective cardinality (explicit one, or the graph default for the key) was already computed in sideEffect() but not used. It is now passed to captureRemovedProperty().

Testing:

  • Added shouldCaptureOldVertexPropertyWhenChangedWithDefaultCardinality to EventStrategyProcessTest. It is skipped for graphs whose default cardinality for the key is not single.
  • Ran EventStrategyProcessTest through TinkerGraphProcessStandardTest: passes with the fix, fails without it.

Merge notes: the code differs on 3.8-dev, the fallback cardinality is computed after the call to captureRemovedProperty(), so it needs to be moved above it when merging forward.

@paul-lartigau paul-lartigau changed the title TINKERPOP-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified. TINKERPOP-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified Oct 13, 2026
// find property to remove. only need to capture the removedProperty if eventing is configured
final Property removedProperty = eventingIsConfigured ?
captureRemovedProperty(element, key, value, es) :
captureRemovedProperty(element, key, value, effectiveCardinality, es) :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 3.7, this cardinality is used only for event capture. The actual write below still calls vertex.property(key, value) when cardinality is omitted, and providers may implement that differently from getCardinality(key), which is documented as potentially only a hint. This could cause the event to report a replacement when the provider actually appended, or miss a replacement when it wrote as single. I fully agree with your fix on 3.8-dev though.

Do you need this fix on 3.7.x or can we just apply it to 3.8.x?

@paul-lartigau paul-lartigau Oct 14, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I missed that. I've patched it on my side in a fork for now, so applying it to 3.8.x only is fine, and I'll pick it up there later. I've retargeted this PR to 3.8-dev.

…t cardinality

Assisted-by: Claude Code:claude-opus-5-5
@paul-lartigau
paul-lartigau changed the base branch from 3.7-dev to 3.8-dev October 14, 2026 08:46
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldCaptureOldVertexPropertyWhenChangedWithDefaultCardinality() {
assumeTrue(graph.features().vertex().getCardinality("to-change") == VertexProperty.Cardinality.single);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix also changes behavior when the graph’s default cardinality is set, but this test only runs for default single cardinality. Please add a second test for default set and ensure it executes with TinkerGraph by configuring TinkerGraphProvider#getBaseConfiguration() for that test method, following the existing pattern.

@kenhuuu

kenhuuu commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Thank you for reporting this issue and contributing a fix. It's very much appreciated.

VOTE +1

@codecov-commenter

codecov-commenter commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (3.8-dev@c7538d1). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ess/traversal/step/sideEffect/AddPropertyStep.java 62.50% 0 Missing and 3 partials ⚠️
.../strategy/decoration/EventStrategyProcessTest.java 85.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             3.8-dev    #3715   +/-   ##
==========================================
  Coverage           ?   76.97%           
  Complexity         ?    15063           
==========================================
  Files              ?     1162           
  Lines              ?    72576           
  Branches           ?     8131           
==========================================
  Hits               ?    55867           
  Misses             ?    13732           
  Partials           ?     2977           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants