Fix XREAD returning error on empty stream with + ID

When using XREAD STREAMS <stream> + on an empty stream created with MKSTREAM, valkey returns an error instead of nil.

This heppens because is missing a check on the stream length

The fix adds the lenght check on the condition

Fixes #2728

Signed-off-by: diego-ciciani01 <diego.ciciani@gmail.com>
This commit is contained in:
diego-ciciani01 2025-10-16 19:27:52 +02:00
parent 981b8fe1bd
commit bf4488d67c
1 changed files with 1 additions and 1 deletions

View File

@ -2275,7 +2275,7 @@ void xreadCommand(client *c) {
"just return an empty result set.");
goto cleanup;
}
if (o) {
if (o && ((stream *)o->ptr)->length) {
stream *s = o->ptr;
ids[id_idx] = s->last_id;
if (streamDecrID(&ids[id_idx]) != C_OK) {