You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "paul-lartigau (via GitHub)" <gi...@apache.org> on 2026/10/13 09:32:41 UTC

[PR] TINKERPOP-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified. [tinkerpop]

paul-lartigau opened a new pull request, #3715:
URL: https://github.com/apache/tinkerpop/pull/3715

   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.


-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4343344095


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java:
##########
@@ -153,7 +154,7 @@ private Property captureRemovedProperty(final Element element, final String key,
                         break;
                     }
                 }
-            } else if (cardinality == VertexProperty.Cardinality.single) {
+            } else if (effectiveCardinality == VertexProperty.Cardinality.single) {
                 removedProperty = element.property(key);

Review Comment:
   On further inspection, I think there's actually a deeper pre-existing bug here in `captureRemovedProperty`, which is actually worsened by this fix.
   
   The whole intent of this method is very clear under the assumption that properties only ever have single cardinality. Writing a property on an existing key results in an overwrite, which triggers events for one property removal, and one addition. It still works ok for always `set` graphs (logs a remove and add if a matching property is already present in the Set) as well as `list` graphs (nothing ever gets removed).
   
   Where this logic fails is if the new property is changing the existing cardinality.
   
   Consider the following example:
   
   ```
   gremlin> g.addV().property(list, "email", "a@b.com").property(list, "email", "c@d.com")
   ==>v[0]
   gremlin> g.V().valueMap()
   ==>[email:[a@b.com,c@d.com]]
   gremlin> g.V().property(single, "email", "x@y.com")
   ==>v[0]
   gremlin> g.V().valueMap()
   ==>[email:[x@y.com]]
   ```
   
   During that second AddProperty, all the pre-existing list entries are dropped. In this case we don't need to capture a single removed property, we need to capture many. The same applies for replacing `Set` with `Single`
   
   This is a pre-existing bug, which is actually worse than simply missing removed property events, as this call to `element.property(key)` will actually throw an exception if this already more than 1 property associated with the key. The issue with respect to this PR, is it actually makes this code path more likely to be hit, as it existing `cardinality = null` no-op case, with the much more common `effectiveCardinality = default cardinality (often single)` case.
   
   Fixing this bug is a bigger change, as we need to rework the removed property mechanism to track whole lists of removed properties. @paul-lartigau I'll let you decide how you wish to proceed with this PR. We could include the full fix to this other bug before proceeding, or if you want to get this PR in now (as it is a self-contained fix it its own right), I would suggest we make the temporary patch with a reference to a new JIRA:
   
   ```suggestion
                   // Only tracks the first removed property, potentially missing events if existing cardinality was Set or List. TINKERPOP-XXXX
                   removedProperty = element.properties(key).next();
   ```
   
   This would at least bypass the potential for an exception, which would ensure no regressions from this change.
   
   Let me know how you wish to proceed.



-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer merged PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715


-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#issuecomment-6172684929

   Thank you for reporting this issue and contributing a fix. It's very much appreciated.
   
   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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4384324741


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java:
##########
@@ -153,7 +154,7 @@ private Property captureRemovedProperty(final Element element, final String key,
                         break;
                     }
                 }
-            } else if (cardinality == VertexProperty.Cardinality.single) {
+            } else if (effectiveCardinality == VertexProperty.Cardinality.single) {
                 removedProperty = element.property(key);

Review Comment:
   I've opened [TINKERPOP-3300](https://issues.apache.org/jira/browse/TINKERPOP-3300) to track this issue. I will push the temporary patch suggested here and proceed with merging this PR.



-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "paul-lartigau (via GitHub)" <gi...@apache.org>.
paul-lartigau commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4268438281


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java:
##########
@@ -126,7 +126,7 @@ protected void sideEffect(final Traverser.Admin<S> traverser) {
 
         // 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) :

Review Comment:
    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'll retarget this PR to 3.8-dev.



##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java:
##########
@@ -126,7 +126,7 @@ protected void sideEffect(final Traverser.Admin<S> traverser) {
 
         // 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) :

Review Comment:
   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'll retarget this PR to 3.8-dev.



-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4266501359


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java:
##########
@@ -126,7 +126,7 @@ protected void sideEffect(final Traverser.Admin<S> traverser) {
 
         // 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) :

Review Comment:
   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?



-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#issuecomment-6323250364

   I'm going to give CI some time to execute (we're a bit short on runners at the moment), I plan to merge this later today if everything is green.


-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#issuecomment-6174621531

   ## [Codecov](https://app.codecov.io/gh/apache/tinkerpop/pull/3715?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `78.57143%` with `6 lines` in your changes missing coverage. Please review.
   :warning: Please [upload](https://docs.codecov.com/docs/codecov-uploader) report for BASE (`3.8-dev@c7538d1`). [Learn more](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#section-missing-base-commit) about missing BASE report.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/tinkerpop/pull/3715?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...ess/traversal/step/sideEffect/AddPropertyStep.java](https://app.codecov.io/gh/apache/tinkerpop/pull/3715?src=pr&el=tree&filepath=gremlin-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Ftinkerpop%2Fgremlin%2Fprocess%2Ftraversal%2Fstep%2FsideEffect%2FAddPropertyStep.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JlbWxpbi1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS90aW5rZXJwb3AvZ3JlbWxpbi9wcm9jZXNzL3RyYXZlcnNhbC9zdGVwL3NpZGVFZmZlY3QvQWRkUHJvcGVydHlTdGVwLmphdmE=) | 62.50% | [0 Missing and 3 partials :warning: ](https://app.codecov.io/gh/apache/tinkerpop/pull/3715?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../strategy/decoration/EventStrategyProcessTest.java](https://app.codecov.io/gh/apache/tinkerpop/pull/3715?src=pr&el=tree&filepath=gremlin-test%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Ftinkerpop%2Fgremlin%2Fprocess%2Ftraversal%2Fstrategy%2Fdecoration%2FEventStrategyProcessTest.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JlbWxpbi10ZXN0L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS90aW5rZXJwb3AvZ3JlbWxpbi9wcm9jZXNzL3RyYXZlcnNhbC9zdHJhdGVneS9kZWNvcmF0aW9uL0V2ZW50U3RyYXRlZ3lQcm9jZXNzVGVzdC5qYXZh) | 85.00% | [1 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/tinkerpop/pull/3715?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##             3.8-dev    #3715   +/-   ##
   ==========================================
     Coverage           ?   76.73%           
     Complexity         ?    15063           
   ==========================================
     Files              ?     1134           
     Lines              ?    66490           
     Branches           ?     8131           
   ==========================================
     Hits               ?    51020           
     Misses             ?    12725           
     Partials           ?     2745           
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/tinkerpop/pull/3715?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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "paul-lartigau (via GitHub)" <gi...@apache.org>.
paul-lartigau commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4387527699


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java:
##########
@@ -153,7 +154,7 @@ private Property captureRemovedProperty(final Element element, final String key,
                         break;
                     }
                 }
-            } else if (cardinality == VertexProperty.Cardinality.single) {
+            } else if (effectiveCardinality == VertexProperty.Cardinality.single) {
                 removedProperty = element.property(key);

Review Comment:
   Thanks for the review.
   I wasn't aware of this issue, I use JanusGraph, where cardinality is fixed by the schema, so I never ran into it.



-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#issuecomment-6323232170

   Thanks for identifying this issue and implementing the fix. The change looks good to me.
   
   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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "paul-lartigau (via GitHub)" <gi...@apache.org>.
paul-lartigau commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4268438281


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/AddPropertyStep.java:
##########
@@ -126,7 +126,7 @@ protected void sideEffect(final Traverser.Admin<S> traverser) {
 
         // 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) :

Review Comment:
   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.



-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4273222599


##########
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java:
##########
@@ -1051,6 +1052,39 @@ public void vertexPropertyChanged(final Vertex element, final VertexProperty old
         assertThat(triggered.get(), is(true));
     }
 
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldCaptureOldVertexPropertyWhenChangedWithDefaultCardinality() {
+        assumeTrue(graph.features().vertex().getCardinality("to-change") == VertexProperty.Cardinality.single);

Review Comment:
   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.



-- 
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-3294: AddPropertyStep does not capture the old property for EventStrategy when cardinality is not specified [tinkerpop]

Posted by "paul-lartigau (via GitHub)" <gi...@apache.org>.
paul-lartigau commented on code in PR #3715:
URL: https://github.com/apache/tinkerpop/pull/3715#discussion_r4335767110


##########
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java:
##########
@@ -1051,6 +1052,39 @@ public void vertexPropertyChanged(final Vertex element, final VertexProperty old
         assertThat(triggered.get(), is(true));
     }
 
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldCaptureOldVertexPropertyWhenChangedWithDefaultCardinality() {
+        assumeTrue(graph.features().vertex().getCardinality("to-change") == VertexProperty.Cardinality.single);

Review Comment:
   Thanks for the review. I added the test for default `set` cardinality
   (`shouldCaptureOldVertexPropertyWhenChangedWithDefaultSetCardinality`), configured
   through `TinkerGraphProvider#getBaseConfiguration()` (and the same for
   `TinkerTransactionGraphProvider`) following the existing pattern.
   
   I also added two tests that Codecov flagged as uncovered:
   - `set` with a value that is not yet present (no old property captured)
   - default `list` cardinality (no old property captured; behavior unchanged by the fix)
   
   I confirmed that the single and set tests fail without the fix. Squashed into a
   single commit.



-- 
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