LPOS with COUNT replies with bulk strings instead of integers

Aperta
#3,776 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@DeviousDrops ci sta già lavorando.

Dal 10/11/2026.

  • #3777 di @DeviousDrops — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
cpp
Ambito
backend, databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C++
Stelle
4.5k
Fork
689
Merge medio
1g 23h
PR unite (30g)
36

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/kvrocks

Tutte le issue di apache/kvrocks

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.