imbajin commented on code in PR #383:
URL: https://github.com/apache/hugegraph-ai/pull/383#discussion_r4292842852


##########
hugegraph-llm/src/tests/utils/mock.py:
##########
@@ -74,3 +79,34 @@ def __len__(self):
     def search(self, query_vector, top_k=5):
         # Simply return the first top_k documents.
         return self.documents[: min(top_k, len(self.documents))]
+
+
+class FakeGremlinEndpoint:
+    """Stand-in for HugeGraph's /gremlin endpoint that rejects scripts whose 
g.V(...) ids don't parse.
+
+    Groovy and Python share the same rules for single-quoted literals with \\' 
and \\\\ escapes,
+    so ast.literal_eval acts as the parser. Vertex lookups return matching 
entries from `vertices`;
+    traversals (anything with `.repeat(`) return the `paths` that start at one 
of the requested ids.
+    """
+
+    def __init__(self, vertices, paths=None):
+        self.vertices = vertices
+        self.paths = paths or []
+        self.scripts = []
+
+    def exec(self, gremlin):
+        self.scripts.append(gremlin)
+        match = re.match(r"g\.V\((.*?)\)\s*[.\n]", gremlin, re.S)

Review Comment:
   ⚠️ Important. Blocking: no. Summary: This pattern stops at the first `)` 
followed by `.` even inside a quoted ID, so `g.V('x).y').limit(8)` is truncated 
to `'x` and rejected by `ast.literal_eval`. Please scan the call boundary while 
respecting quoted and escaped content, and cover this valid ID. Evidence: 
static inspection of `FakeGremlinEndpoint.exec` at this head.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to