From d90c82ffe4bcccef5ce123fe374a7343926e17d7 Mon Sep 17 00:00:00 2001
From: laura-ding <48548375+laura-ding@users.noreply.github.com>
Date: Thu, 24 Dec 2020 10:47:47 +0800
Subject: [PATCH] Add session 0 processing (#470)

Co-authored-by: jie.wang <38901892+jievince@users.noreply.github.com>
Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
---
 src/service/GraphService.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/service/GraphService.cpp b/src/service/GraphService.cpp
index 562963dc..7538a147 100644
--- a/src/service/GraphService.cpp
+++ b/src/service/GraphService.cpp
@@ -66,11 +66,18 @@ GraphService::future_execute(int64_t sessionId, const std::string& query) {
     ctx->setRunner(getThreadManager());
     auto future = ctx->future();
     {
+        // When the sessionId is 0, it means the clients to ping the connection is ok
+        if (sessionId == 0) {
+            ctx->resp().errorCode = ErrorCode::E_SESSION_INVALID;
+            ctx->resp().errorMsg = std::make_unique<std::string>("The Session id is not valid");
+            ctx->finish();
+            return future;
+        }
         auto result = sessionManager_->findSession(sessionId);
         if (!result.ok()) {
             FLOG_ERROR("Session not found, id[%ld]", sessionId);
             ctx->resp().errorCode = ErrorCode::E_SESSION_INVALID;
-            // ctx->resp().set_error_msg(result.status().toString());
+            ctx->resp().errorMsg = std::make_unique<std::string>(result.status().toString());
             ctx->finish();
             return future;
         }
-- 
GitLab