mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix(json_family): Fix JSON.GET crash for the multiple legacy mode paths (#3582)
fixes dragonflydb#3558 Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
This commit is contained in:
parent
f4fd0f1a07
commit
832b79563d
2 changed files with 9 additions and 1 deletions
|
@ -572,7 +572,9 @@ OpResult<std::string> OpJsonGet(const OpArgs& op_args, string_view key,
|
|||
} else {
|
||||
for (const auto& [path_str, path] : paths) {
|
||||
auto eval_result = eval_wrapped(path);
|
||||
DCHECK(eval_result);
|
||||
if (legacy_mode_is_enabled && !eval_result) {
|
||||
return OpStatus::INVALID_JSON_PATH;
|
||||
}
|
||||
out[path_str] = std::move(eval_result).value(); // TODO(Print not existing path to the user)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,6 +152,12 @@ TEST_F(JsonFamilyTest, GetLegacy) {
|
|||
resp = Run({"JSON.GET", "json", "bar"}); // V1 Response
|
||||
ASSERT_THAT(resp, ErrArg("ERR invalid JSON path"));
|
||||
|
||||
resp = Run({"JSON.GET", "json", ".", "bar"}); // V1 Response
|
||||
ASSERT_THAT(resp, ErrArg("ERR invalid JSON path"));
|
||||
|
||||
resp = Run({"JSON.GET", "json", ".a", "bar", "foo", "third", "."}); // V1 Response
|
||||
ASSERT_THAT(resp, ErrArg("ERR invalid JSON path"));
|
||||
|
||||
resp = Run({"JSON.GET", "json", "$.bar"}); // V2 Response
|
||||
ASSERT_THAT(resp, "[]");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue