go-redis/redis · error
redis: negative push notification name length: %d
Error message
redis: negative push notification name length: %d
What it means
Error "redis: negative push notification name length: %d" thrown in go-redis/redis.
Source
Thrown at internal/proto/reader.go:239
if typeOfName == RespString {
// Read "$M\r\n" then the M-byte name.
lenStart := pos
next, ok, err := skipDigitsThenCRLF(buf, pos)
if err != nil {
return "", false, fmt.Errorf("redis: can't parse push notification name length: %w", err)
}
if !ok {
return "", false, nil
}
if next-2 == lenStart {
return "", false, fmt.Errorf("redis: empty push notification name length")
}
nameLen, err := util.Atoi(buf[lenStart : next-2])
if err != nil {
return "", false, fmt.Errorf("redis: invalid push notification name length %q: %w", buf[lenStart:next-2], err)
}
if nameLen < 0 {
return "", false, fmt.Errorf("redis: negative push notification name length: %d", nameLen)
}
// Compare against the remaining bytes instead of computing
// next+nameLen: a hugely advertised length on malformed input could
// overflow int, wrap negative, slip past an "end > len(buf)" guard and
// panic the slice below. next <= len(buf) here, so the subtraction is
// safe.
if nameLen > len(buf)-next {
return "", false, nil
}
return util.BytesToString(buf[next : next+nameLen]), true, nil
}
// RespStatus: scan for the terminating CRLF.
for i := pos; i < len(buf)-1; i++ {
if buf[i] == '\r' && buf[i+1] == '\n' {
return util.BytesToString(buf[pos:i]), true, nil
}
}View on GitHub (pinned to 36d97525cd)
Solutions
- Reconnect; negative length indicates stream desynchronization or a protocol violation
- Verify TLS/proxy layers are not corrupting bytes
When it happens
Trigger: Thrown at internal/proto/reader.go:239 when the library encounters an invalid state.
Common situations: Never continue reading after a negative length parse error.
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/e3132b867241a127.json.
Report an issue: GitHub.