LPOS with COUNT replies with bulk strings instead of integers

Abierto
#3,776 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@DeviousDrops ya está trabajando en esto.

Desde el 10/11/2026.

  • #3777 de @DeviousDrops — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cpp

Línea de trabajo

Start in src/commands/cmd_list.cc at CommandLPos::Execute, especially the lines that convert matching indexes and build the COUNT reply. Check the existing command tests for LPOS COUNT reply types, then run the relevant test after changing the response. Done means COUNT replies contain integer elements while preserving the documented empty-array and no-COUNT behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Search before asking
  • I had searched in the issues and found no similar issues.
Version
  • Kvrocks: unstable, commit 84e88322
  • Compared with Redis 7.2.17 and Redis 8.0.5
Minimal reproduce step
DEL l
RPUSH l a b a
LPOS l a COUNT 1
LPOS l a COUNT 0
LPOS l a RANK -1 COUNT 2
What did you expect to see?

An array of integers, as in Redis. Redis 7.2.17 and 8.0.5 give the same output (redis-cli --no-raw):

> LPOS l a COUNT 1
1) (integer) 0
> LPOS l a COUNT 0
1) (integer) 0
2) (integer) 2
> LPOS l a RANK -1 COUNT 2
1) (integer) 2
2) (integer) 0

The LPOS docs say, for both RESP2 and RESP3:

Array reply: If the COUNT option is given, an array of integers representing the matching elements (or an empty array if there are no matches).

What did you see instead?

Kvrocks returns an array of bulk strings:

> LPOS l a COUNT 1
1) "0"
> LPOS l a COUNT 0
1) "0"
2) "2"
> LPOS l a RANK -1 COUNT 2
1) "2"
2) "0"

LPOS without COUNT already returns an integer (or nil) correctly, and the no-match case with COUNT returns an empty array correctly. Only the element type inside the COUNT array is wrong.

Anything Else?

The cause is in CommandLPos::Execute (src/commands/cmd_list.cc:886-891 on unstable). The indexes are converted with std::to_string() and sent with ArrayOfBulkStrings(), so each element is a bulk string instead of an integer reply.

The existing Go tests don't catch this because go-redis's LPosCount parses bulk strings like "2" into int64 without complaint. Clients that check reply types (or RESP3 clients that map types strictly) see strings.

Are you willing to submit a PR?
  • I'm willing to submit a PR!

I'd like to work on this.

Lenguaje dominante
C++
Estrellas
4.5k
Forks
689
Merge medio
1 d 23 h
PR fusionados (30 d)
36

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/kvrocks

Todos los issues de apache/kvrocks

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.