From e914a5f7cfff15f92c5100a3750b8e6af39d4986 Mon Sep 17 00:00:00 2001 From: Stepan Bagritsevich <43710058+BagritsevichStepan@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:02:33 +0400 Subject: [PATCH] fix(json_family): Fix error in JsonFamilyTest.MGet (#3285) * fix(json_family): Fix error in JsonFamilyTest.MGet Signed-off-by: Stepan Bagritsevich * refactor(json_family): address comments Signed-off-by: Stepan Bagritsevich * refactor(json_family): Change LOG(WARNING) to VLOG(2) Signed-off-by: Stepan Bagritsevich * fix(json_family): Test case when jsonpathv2 is false Signed-off-by: Stepan Bagritsevich * refactor(json_family): Update VLOGs level from 2 to 1 Signed-off-by: Stepan Bagritsevich --------- Signed-off-by: Stepan Bagritsevich --- .github/workflows/ci.yml | 1 + src/server/json_family.cc | 8 +++++++- src/server/json_family_test.cc | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c3eb7306..25f9783e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -156,6 +156,7 @@ jobs: ./dragonfly_test ./multi_test --multi_exec_mode=1 ./multi_test --multi_exec_mode=3 + ./json_family_test --jsonpathv2=false - name: Upload unit logs on failure if: failure() diff --git a/src/server/json_family.cc b/src/server/json_family.cc index f80b44731..2330df0a1 100644 --- a/src/server/json_family.cc +++ b/src/server/json_family.cc @@ -1447,10 +1447,16 @@ io::Result ParsePathV2(string_view path) { } if (absl::GetFlag(FLAGS_jsonpathv2)) { - return json::ParsePath(path); + auto path_result = json::ParsePath(path); + if (!path_result) { + VLOG(1) << "Invalid Json path: " << path << ' ' << path_result.error() << std::endl; + return nonstd::make_unexpected(kSyntaxErr); + } + return path_result; } io::Result expr_result = ParseJsonPath(path); if (!expr_result) { + VLOG(1) << "Invalid Json path: " << path << ' ' << expr_result.error() << std::endl; return nonstd::make_unexpected(kSyntaxErr); } return JsonPathV2(std::move(expr_result.value())); diff --git a/src/server/json_family_test.cc b/src/server/json_family_test.cc index ed0b55dd1..dc6166850 100644 --- a/src/server/json_family_test.cc +++ b/src/server/json_family_test.cc @@ -982,7 +982,7 @@ TEST_F(JsonFamilyTest, MGet) { #ifndef SANITIZERS resp = Run({"JSON.MGET", "json1", "??INNNNVALID??"}); - EXPECT_THAT(resp, ErrArg("Unknown token")); + EXPECT_THAT(resp, ErrArg("ERR syntax error")); #endif resp = Run({"JSON.MGET", "json1", "json2", "json3", "$.address.country"});