You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ke...@apache.org on 2023/10/27 05:45:52 UTC

[tinkerpop] branch TINKERPOP-2988 updated: updates to make graphbinary work as well

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

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


The following commit(s) were added to refs/heads/TINKERPOP-2988 by this push:
     new f9dd65ac8e updates to make graphbinary work as well
f9dd65ac8e is described below

commit f9dd65ac8e9c66f822963b2a18adbb3a7d77cd51
Author: Ken Hu <10...@users.noreply.github.com>
AuthorDate: Thu Oct 26 22:44:48 2023 -0700

    updates to make graphbinary work as well
---
 .../lib/structure/io/binary/internals/UuidSerializer.js     |  4 ++++
 .../gremlin-javascript/test/integration/client-tests.js     | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/UuidSerializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/UuidSerializer.js
index 9ec8a39080..c7602b074d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/UuidSerializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/UuidSerializer.js
@@ -46,6 +46,10 @@ module.exports = class UuidSerializer {
       .replace(/^urn:uuid:/, '')
       .replace(/[{}-]/g, '');
 
+    if (!uuid_str.match('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')) {
+      throw new Error(uuid_str + ' is not a valid UUID.');
+    }
+
     const bufs = [];
     if (fullyQualifiedFormat) {
       bufs.push(Buffer.from([this.ioc.DataType.UUID, 0x00]));
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
index 04db370ef7..a9970c86ce 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
@@ -117,8 +117,17 @@ describe('Client', function () {
         }
       } catch (e) {
         assert.ok(e);
-        assert.ok(e.statusMessage);
-        assert.ok(e.statusMessage.includes("UUID has to be represented by standard 36-char representation"));
+
+        // GraphBinary and GraphSON return different errors.
+        if (e.statusMessage) {
+          // Invalid UUID for GraphSON is parsed on the server side.
+          assert.ok(e.statusMessage);
+          assert.ok(e.statusMessage.includes("UUID has to be represented by standard 36-char representation"));
+        } else {
+          // Invalid UUID for GraphBinary is checked by the driver.
+          assert.ok(e.message);
+          assert.ok(e.message.includes("malformed is not a valid UUID."));
+        }
       }
     });