fix: JSON.ARRPOP command crash fixed (#5026)

fixed: https://github.com/dragonflydb/dragonfly/issues/5025
This commit is contained in:
Volodymyr Yavdoshenko 2025-04-30 08:00:01 +03:00 committed by GitHub
parent 13d8062bb9
commit 84456a2442
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -1794,6 +1794,10 @@ void JsonFamily::ArrPop(CmdArgList args, const CommandContext& cmd_cntx) {
int index = parser.NextOrDefault<int>(-1);
auto* builder = static_cast<RedisReplyBuilder*>(cmd_cntx.rb);
if (auto err = parser.Error(); err) {
return builder->SendError(err->MakeReply());
}
WrappedJsonPath json_path = GET_OR_SEND_UNEXPECTED(ParseJsonPath(path));
auto cb = [&](Transaction* t, EngineShard* shard) {

View file

@ -3074,4 +3074,9 @@ TEST_F(JsonFamilyTest, SetNestedFields) {
EXPECT_EQ(resp, R"({"-field2":2,"field1":1})");
}
TEST_F(JsonFamilyTest, ArrPopWithFormatParameter) {
auto resp = Run({"JSON.ARRPOP", "test_resp3", "FORMAT", "EXPAND", "$.a"});
ASSERT_THAT(resp, ErrArg("value is not an integer or out of range"));
}
} // namespace dfly