bitflicker64 commented on code in PR #3289:
URL: https://github.com/apache/hugegraph/pull/3289#discussion_r4217949062


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java:
##########
@@ -102,12 +106,74 @@ public class CypherOpProcessor extends 
AbstractEvalOpProcessor {
     private static final String DEFAULT_TRANSLATOR_DEFINITION =
             "gremlin+cfog_server_extensions+inline_parameters";
 
+    // translation 1.0.4 uses this string as null and cannot preserve it as 
bound data.
+    private static final String RESERVED_NULL_VALUE = "  cypher.null";
+
     private static final Logger logger = getLogger(CypherOpProcessor.class);
 
     public CypherOpProcessor() {
         super(true);
     }
 
+    @Override
+    protected Optional<ThrowingConsumer<Context>> 
validateEvalMessage(RequestMessage message)
+            throws OpProcessorException {
+        Object query = message.getArgs().get(Tokens.ARGS_GREMLIN);
+        String error = null;
+        if (!(query instanceof String) || ((String) query).isBlank()) {
+            error = "The Cypher query must be a nonblank string";
+        } else if (message.getArgs().containsKey(Tokens.ARGS_BINDINGS)) {
+            Object supplied = message.getArgs().get(Tokens.ARGS_BINDINGS);
+            if (!(supplied instanceof Map)) {
+                error = "Cypher bindings must be a map";
+            } else {
+                Map<?, ?> bindings = (Map<?, ?>) supplied;
+                if (bindings.size() > this.maxParameters) {

Review Comment:
   Minor: `this.maxParameters` is always `DEFAULT_MAX_PARAMETERS` (16) for this 
processor. In TinkerPop 3.8.1 only `StandardOpProcessor.init(Settings)` reads 
`maxParameters` from the processor config, and `CypherOpProcessor` does not 
override `init`. An operator also cannot add it: `getTranslatorDefinition` 
throws `IllegalStateException("Unknown configuration parameters found for 
CypherOpProcessor: [maxParameters]")` for any key except 
`translatorDefinition`/`translatorFeatures`, so every Cypher request would 
fail. This PR exposes bindings on the REST endpoint, so a parameterised 
`CREATE` with 17 properties is now rejected, and `docs/cypher-compatibility.md` 
calls 16 "the default limit", which suggests it can be changed. Please either 
override `init` to read `maxParameters` from 
`settings.optionalProcessor(CypherOpProcessor.class)` and allow that key in 
`getTranslatorDefinition`, or document the limit as fixed and point users to a 
single map parameter (`CREATE (n:person $props)`) as 
 the workaround.



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