Skip to content

Commit

Permalink
fix(json_family): Fix error in JsonFamilyTest.MGet (#3285)
Browse files Browse the repository at this point in the history
* fix(json_family): Fix error in JsonFamilyTest.MGet

Signed-off-by: Stepan Bagritsevich <[email protected]>

* refactor(json_family): address comments

Signed-off-by: Stepan Bagritsevich <[email protected]>

* refactor(json_family): Change LOG(WARNING) to VLOG(2)

Signed-off-by: Stepan Bagritsevich <[email protected]>

* fix(json_family): Test case when jsonpathv2 is false

Signed-off-by: Stepan Bagritsevich <[email protected]>

* refactor(json_family): Update VLOGs level from 2 to 1

Signed-off-by: Stepan Bagritsevich <[email protected]>

---------

Signed-off-by: Stepan Bagritsevich <[email protected]>
  • Loading branch information
BagritsevichStepan authored Jul 9, 2024
1 parent 628985b commit e914a5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 7 additions & 1 deletion src/server/json_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1447,10 +1447,16 @@ io::Result<JsonPathV2, string> 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<JsonExpression> 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()));
Expand Down
2 changes: 1 addition & 1 deletion src/server/json_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"});
Expand Down

0 comments on commit e914a5f

Please sign in to comment.