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

kenhuuu pushed a commit to branch 3.7-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/3.7-dev by this push:
     new fde92e7792 TINKERPOP-3230 Add logging for missing fields in GraphSON 
response CTR
fde92e7792 is described below

commit fde92e7792f1cc6a170c6564cbb7ee4331685dbb
Author: Ken Hu <[email protected]>
AuthorDate: Mon Mar 30 16:30:59 2026 -0700

    TINKERPOP-3230 Add logging for missing fields in GraphSON response CTR
---
 .../util/ser/AbstractGraphSONMessageSerializerV1.java  | 18 ++++++++++++++++--
 .../util/ser/AbstractGraphSONMessageSerializerV2.java  | 18 ++++++++++++++++--
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git 
a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV1.java
 
b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV1.java
index 58a702e1eb..c2a0de62fd 100644
--- 
a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV1.java
+++ 
b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV1.java
@@ -42,6 +42,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
@@ -135,12 +136,25 @@ public abstract class AbstractGraphSONMessageSerializerV1 
extends AbstractMessag
             final Map<String, Object> responseData = mapper.readValue(payload, 
mapTypeReference);
             final Map<String, Object> status = (Map<String, Object>) 
responseData.get(SerTokens.TOKEN_STATUS);
             final Map<String, Object> result = (Map<String, Object>) 
responseData.get(SerTokens.TOKEN_RESULT);
+
+            final Map<String, Object> meta = (Map<String, Object>) 
result.get(SerTokens.TOKEN_META);
+            if (null == meta) {
+                if (logger.isWarnEnabled())
+                    logger.warn("Response is missing the 'meta' field in the 
result - defaulting to an empty map.");
+            }
+
+            final Map<String, Object> statusAttributes = (Map<String, Object>) 
status.get(SerTokens.TOKEN_ATTRIBUTES);
+            if (null == statusAttributes) {
+                if (logger.isWarnEnabled())
+                    logger.warn("Response is missing the 'attributes' field in 
the status - defaulting to an empty map.");
+            }
+
             return 
ResponseMessage.build(UUID.fromString(responseData.get(SerTokens.TOKEN_REQUEST).toString()))
                     .code(ResponseStatusCode.getFromValue((Integer) 
status.get(SerTokens.TOKEN_CODE)))
                     
.statusMessage(String.valueOf(status.get(SerTokens.TOKEN_MESSAGE)))
-                    .statusAttributes((Map<String, Object>) 
status.get(SerTokens.TOKEN_ATTRIBUTES))
+                    .statusAttributes(null == statusAttributes ? 
Collections.emptyMap() : statusAttributes)
                     .result(result.get(SerTokens.TOKEN_DATA))
-                    .responseMetaData((Map<String, Object>) 
result.get(SerTokens.TOKEN_META))
+                    .responseMetaData(null == meta ? Collections.emptyMap() : 
meta)
                     .create();
         } catch (Exception ex) {
             logger.warn("Response [{}] could not be deserialized by {}.", msg, 
AbstractGraphSONMessageSerializerV1.class.getName());
diff --git 
a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV2.java
 
b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV2.java
index a67b8ffdbf..bf66da59e3 100644
--- 
a/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV2.java
+++ 
b/gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/AbstractGraphSONMessageSerializerV2.java
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Map;
 import java.util.UUID;
 
@@ -294,12 +295,25 @@ public abstract class AbstractGraphSONMessageSerializerV2 
extends AbstractMessag
         public ResponseMessage createObject(final Map<String, Object> data) {
             final Map<String, Object> status = (Map<String, Object>) 
data.get(SerTokens.TOKEN_STATUS);
             final Map<String, Object> result = (Map<String, Object>) 
data.get(SerTokens.TOKEN_RESULT);
+
+            final Map<String, Object> meta = (Map<String, Object>) 
result.get(SerTokens.TOKEN_META);
+            if (null == meta) {
+                if (logger.isWarnEnabled())
+                    logger.warn("Response is missing the 'meta' field in the 
result - defaulting to an empty map.");
+            }
+
+            final Map<String, Object> statusAttributes = (Map<String, Object>) 
status.get(SerTokens.TOKEN_ATTRIBUTES);
+            if (null == statusAttributes) {
+                if (logger.isWarnEnabled())
+                    logger.warn("Response is missing the 'attributes' field in 
the status - defaulting to an empty map.");
+            }
+
             return 
ResponseMessage.build(UUID.fromString(data.get(SerTokens.TOKEN_REQUEST).toString()))
                     .code(ResponseStatusCode.getFromValue((Integer) 
status.get(SerTokens.TOKEN_CODE)))
                     
.statusMessage(String.valueOf(status.get(SerTokens.TOKEN_MESSAGE)))
-                    .statusAttributes((Map<String, Object>) 
status.get(SerTokens.TOKEN_ATTRIBUTES))
+                    .statusAttributes(null == statusAttributes ? 
Collections.emptyMap() : statusAttributes)
                     .result(result.get(SerTokens.TOKEN_DATA))
-                    .responseMetaData((Map<String, Object>) 
result.get(SerTokens.TOKEN_META))
+                    .responseMetaData(null == meta ? Collections.emptyMap() : 
meta)
                     .create();
         }
     }

Reply via email to