This is an automated email from the ASF dual-hosted git repository.

xiazcy pushed a commit to branch steps-taking-traversal-poc
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 0b6985881e2459b3f224ac8035c42d90b3dab21f
Author: Yang Xia <[email protected]>
AuthorDate: Wed May 27 13:57:15 2026 -0700

    update to restrict mutations in all traversal taking steps.
---
 .../process/traversal/util/ChildTraversalValidator.java    | 14 +++-----------
 .../traversal/util/ChildTraversalValidatorTest.java        |  7 ++++---
 .../features/filter/ChildTraversalVerification.feature     | 14 ++++++++++++--
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidator.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidator.java
index 95c422eabe..18b35759a2 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidator.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidator.java
@@ -22,7 +22,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
 
 /**
  * Validates child traversals to ensure they do not contain disallowed steps 
based on the context
@@ -31,8 +30,7 @@ import 
org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
  * <p>
  * Validation rules:
  * <ul>
- *   <li><b>FILTER / LOOKUP context:</b> No steps implementing {@link 
Mutating} are allowed at any nesting depth.</li>
- *   <li><b>MUTATION context:</b> Only {@link DropStep} is blocked; other 
mutating steps are permitted.</li>
+ *   <li><b>FILTER / LOOKUP / MUTATION context:</b> No steps implementing 
{@link Mutating} are allowed at any nesting depth.</li>
  * </ul>
  * <p>
  * Recursion walks both {@link TraversalParent#getLocalChildren()} and
@@ -63,7 +61,7 @@ public final class ChildTraversalValidator {
 
     /**
      * Validates a child traversal used in mutation context 
(property(traversal)).
-     * Throws {@link IllegalArgumentException} if a {@link DropStep} is found.
+     * Throws {@link IllegalArgumentException} if any {@link Mutating} step is 
found.
      */
     public static void validateMutationContext(final Traversal.Admin<?, ?> 
child) {
         validateRecursive(child, ChildTraversalContext.MUTATION);
@@ -91,19 +89,13 @@ public final class ChildTraversalValidator {
         switch (context) {
             case FILTER:
             case LOOKUP:
+            case MUTATION:
                 if (step instanceof Mutating) {
                     throw new IllegalArgumentException(
                             "Child traversal in " + 
context.name().toLowerCase() + " context contains mutating step " +
                             step.getClass().getSimpleName() + ". Mutating 
steps are not allowed in this context.");
                 }
                 break;
-            case MUTATION:
-                if (step instanceof DropStep) {
-                    throw new IllegalArgumentException(
-                            "Child traversal in mutation context contains 
DropStep. " +
-                            "Destructive steps are not allowed inside 
property(traversal).");
-                }
-                break;
             default:
                 break;
         }
diff --git 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidatorTest.java
 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidatorTest.java
index e3b385dd48..b731900276 100644
--- 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidatorTest.java
+++ 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/ChildTraversalValidatorTest.java
@@ -215,9 +215,10 @@ public class ChildTraversalValidatorTest {
     }
 
     @Test
-    public void shouldAllowAddVInMutationContext() {
-        // addV is allowed in property(traversal) — only DropStep is blocked
-        g.V().property(__.V().addV("temp").project("k").by("name"));
+    public void shouldRejectAddVInMutationContext() {
+        // addV is now blocked in property(traversal) — all mutating steps are 
blocked in all contexts
+        assertThrows(IllegalArgumentException.class, () ->
+                g.V().property(__.V().addV("temp").project("k").by("name")));
     }
 
     @Test
diff --git 
a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/ChildTraversalVerification.feature
 
b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/ChildTraversalVerification.feature
index 1bd57ef418..eacf7a972a 100644
--- 
a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/ChildTraversalVerification.feature
+++ 
b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/ChildTraversalVerification.feature
@@ -146,7 +146,7 @@ Feature: Child Traversal Verification - mutating steps 
blocked in filter/lookup
     When iterated to list
     Then the traversal will raise an error with message containing text of 
"mutating step"
 
-  # ===== MUTATION CONTEXT: property(traversal) blocks DropStep but allows 
other mutations =====
+  # ===== MUTATION CONTEXT: property(traversal) blocks ALL mutating steps =====
 
   @GraphComputerVerificationMidVNotSupported
   Scenario: g_V_propertyXV_mapXdropX_projectXxX_byXnameXX_rejected
@@ -156,7 +156,17 @@ Feature: Child Traversal Verification - mutating steps 
blocked in filter/lookup
       g.V().property(__.V().map(__.drop()).project("x").by("name"))
       """
     When iterated to list
-    Then the traversal will raise an error with message containing text of 
"DropStep"
+    Then the traversal will raise an error with message containing text of 
"mutating step"
+
+  @GraphComputerVerificationMidVNotSupported
+  Scenario: g_V_propertyXaddVXtempX_projectXkX_byXnameXX_rejected
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().property(__.addV("temp").project("k").by("name"))
+      """
+    When iterated to list
+    Then the traversal will raise an error with message containing text of 
"mutating step"
 
   # ===== VALID TRAVERSALS: should NOT be rejected =====
 

Reply via email to